* Introduce a WaypointList class to define the interface to our lists of waypoints.
WaypointList is backed QList, eliminating the use of legacy queues for waypoint lists.
* try to appease xcode wrt std::abs.
* clean up inheritence in WaypointList, RouteList.
also quiet clazy with igc and gpsbabel_optional::optional.
also improve includes in defs.h.
* get rid of unnecessary reinterpret_cast.
and correct pointer constness lost by auto.
if (arcpt2 && arcpt2->latitude != BADVAL && arcpt2->longitude != BADVAL &&
(ptsopt || (arcpt1 &&
(arcpt1->latitude != BADVAL && arcpt1->longitude != BADVAL)))) {
-#if NEWQ
- foreach (Waypoint* waypointp, waypt_list) {
-#else
- queue* elem, *tmp;
- QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- Waypoint* waypointp = reinterpret_cast<Waypoint*>(elem);
-#endif
+ foreach (Waypoint* waypointp, *global_waypoint_list) {
double dist;
extra_data* ed;
if (waypointp->extra_data) {
WayptFunctor<ArcDistanceFilter> arcdist_arc_disp_wpt_cb_f(this, &ArcDistanceFilter::arcdist_arc_disp_wpt_cb);
RteHdFunctor<ArcDistanceFilter> arcdist_arc_disp_hdr_cb_f(this, &ArcDistanceFilter::arcdist_arc_disp_hdr_cb);
- queue* elem, * tmp;
-
if (arcfileopt) {
int fileline = 0;
char* line;
}
unsigned removed = 0;
-#if NEWQ
- foreach (Waypoint* wp, waypt_list) {
-#else
- QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- Waypoint* wp = reinterpret_cast<Waypoint *>(elem);
-#endif
+ foreach (Waypoint* wp, *global_waypoint_list) {
extra_data* ed = (extra_data*) wp->extra_data;
wp->extra_data = nullptr;
if (ed) {
2007/04&14: new handling of DESCRIPTION lines
*/
+#include <cmath> // for M_PI, atan, exp, log, tan
+#include <cstdio> // for printf, snprintf, sscanf
+#include <cstdlib> // for atof, atoi
+
+#include <QtCore/QString> // for QString, operator+
+#include <QtCore/Qt> // for CaseInsensitive
+#include <QtCore/QtGlobal> // for foreach
+
#include "defs.h"
-#include "csv_util.h"
-#include "garmin_tables.h"
-#include "inifile.h"
-#include <QtCore/QString>
-#include <cmath>
-#include <cstdio>
-#include <cstdlib>
+#include "csv_util.h" // for csv_stringclean
+#include "garmin_tables.h" // for gt_find_desc_from_icon_number, gt_find_icon_number_from_desc, MAPSOURCE
+#include "gbfile.h" // for gbfprintf, gbfclose, gbfopen, gbfile
+#include "inifile.h" // for inifile_readstr, inifile_done, inifile_init, inifile_t
+
#define MYNAME "bcr"
static void
bcr_create_waypts_from_route(route_head* route)
{
- queue* elem, *tmp;
-
- QUEUE_FOR_EACH(&route->waypoint_list, elem, tmp) {
- Waypoint* wpt = new Waypoint(*reinterpret_cast<Waypoint *>(elem));
- waypt_add(wpt);
+ foreach (const Waypoint* wpt, route->waypoint_list) {
+ waypt_add(new Waypoint(*wpt));
}
}
static void
bcr_route_header(const route_head* route)
{
- queue* elem, *tmp;
- Waypoint* wpt;
int north, east, nmax, emin;
curr_rte_num++;
bcr_write_line(fout, "DESCRIPTIONLINES", nullptr, "0");
int i = 0;
- QUEUE_FOR_EACH(&route->waypoint_list, elem, tmp) {
- Waypoint* wpt = reinterpret_cast<Waypoint *>(elem);
+ foreach (const Waypoint* wpt, route->waypoint_list) {
i++;
int emax = nmax = -nmin;
i = 0;
- QUEUE_FOR_EACH(&route->waypoint_list, elem, tmp) {
+ foreach (const Waypoint* wpt, route->waypoint_list) {
i++;
- wpt = reinterpret_cast<Waypoint *>(elem);
bcr_wgs84_to_mercator(wpt->latitude, wpt->longitude, &north, &east);
bcr_write_line(fout, "[DESCRIPTION]", nullptr, nullptr); /* descr. section */
i = 0;
- QUEUE_FOR_EACH(&route->waypoint_list, elem, tmp) {
+ foreach (const Waypoint* wpt, route->waypoint_list) {
QString s2;
i++;
- wpt = reinterpret_cast<Waypoint *>(elem);
QString s1 = wpt->notes;
if (s1.isEmpty()) {
s1 = wpt->description;
*/
+#include <cmath> // macos wants abs from here!
+#include <cstdlib> // for strtod, abs
+
+#include <QtCore/QString> // for QString
+#include <QtCore/QtGlobal> // for qAsConst, QAddConst<>::Type, foreach
+
#include "defs.h"
-#include "bend.h"
#include "filterdefs.h"
-#include "grtcirc.h"
+#include "bend.h"
+#include "grtcirc.h" // for RAD, heading_true_degrees, gcdist, linepart, radtometers, DEG
-#include <cmath>
-#include <cstdlib>
#define MYNAME "bend"
void BendFilter::process_route(const route_head* route_orig, route_head* route_dest)
{
- Waypoint* wpt_orig_prev = nullptr;
- Waypoint* wpt_orig = nullptr;
+ const Waypoint* wpt_orig_prev = nullptr;
+ const Waypoint* wpt_orig = nullptr;
- queue* elem, *tmp;
- QUEUE_FOR_EACH(&route_orig->waypoint_list, elem, tmp) {
- Waypoint* wpt_orig_next = reinterpret_cast<Waypoint *>(elem);
+ foreach (const Waypoint* wpt_orig_next, route_orig->waypoint_list) {
if (wpt_orig_prev == nullptr) {
if (wpt_orig != nullptr) {
void BendFilter::process()
{
- for (auto it = routes_orig->cbegin(); it != routes_orig->cend(); ++it) {
- auto route_orig = reinterpret_cast<const route_head*>(*it);
+ for (const auto* route_orig : qAsConst(*routes_orig)) {
process_route_orig(route_orig);
}
}
#include "defs.h" // for route_head (ptr only), ARGTYPE_FLOAT, ARG_NOMINMAX
#include "filter.h" // for Filter
-#include "queue.h" // for queue
#if FILTERS_ENABLED
#ifndef DEFS_H_INCLUDED_
#define DEFS_H_INCLUDED_
-#include <cstdint>
+#include <cmath> // for M_PI
+#include <cstdarg> // for va_list
+#include <cstddef> // for NULL, nullptr_t, size_t
+#include <cstdint> // for int32_t, uint32_t
+#include <cstdio> // for NULL, fprintf, FILE, stdout
+#include <ctime> // for time_t
+#include <utility> // for move
#if HAVE_CONFIG_H
#include "config.h"
#endif
-#include "queue.h"
#if HAVE_LIBZ
-#include <zlib.h>
+#include <zlib.h> // doesn't really belong here, but is missing elsewhere.
#elif !ZLIB_INHIBITED
-#include "zlib.h"
+#include "zlib.h" // doesn't really belong here, but is missing elsewhere.
#endif
-#include "gbfile.h"
-#include "inifile.h"
-#include "session.h"
-#include <QtCore/QString>
-#include <QtCore/QTextCodec>
-#include <utility>
-#include "src/core/datetime.h"
-#include "src/core/optional.h"
+#include <QtCore/QByteArray> // for QByteArray
+#include <QtCore/QChar> // for QChar
+#include <QtCore/QList> // for QList, QList<>::const_reverse_iterator, QList<>::reverse_iterator
+#include <QtCore/QString> // for QString
+#include <QtCore/QStringRef> // for QStringRef
+#include <QtCore/QTextCodec> // for QTextCodec
+#include <QtCore/Qt> // for CaseInsensitive
+#include <QtCore/QtGlobal> // for foreach
+
+#include "cet.h" // for cet_cs_vec_t
+#include "inifile.h" // for inifile_t
+#include "gbfile.h" // doesn't really belong here, but is missing elsewhere.
+#include "queue.h" // for queue
+#include "session.h" // for session_t
+#include "src/core/datetime.h" // for DateTime
+#include "src/core/optional.h" // for optional
+
#define CSTR(qstr) ((qstr).toUtf8().constData())
#define CSTRc(qstr) ((qstr).toLatin1().constData())
static geocache_data empty_gc_data;
public:
- queue Q; /* Master waypoint q. Not for use
- by modules. */
double latitude; /* Degrees */
double longitude; /* Degrees */
typedef void (*waypt_cb)(const Waypoint*);
+// TODO: Consider using composition instead of private inheritance.
+class WaypointList : private QList<Waypoint*>
+{
+public:
+ typedef bool (*Compare)(const Waypoint* a, const Waypoint* b);
+
+ void waypt_add(Waypoint* wpt); // a.k.a. append(), push_back()
+ void add_rte_waypt(int waypt_ct, Waypoint* wpt, bool synth, const QString& namepart, int number_digits);
+ // FIXME: Generally it is inefficient to use an element pointer or reference to define the element to be deleted, use iterator instead,
+ // and/or implement pop_back() a.k.a. removeLast(), and/or pop_front() a.k.a. removeFirst().
+ void waypt_del(Waypoint* wpt); // a.k.a. erase()
+ // FIXME: Generally it is inefficient to use an element pointer or reference to define the element to be deleted, use iterator instead,
+ // and/or implement pop_back() a.k.a. removeLast(), and/or pop_front() a.k.a. removeFirst().
+ void del_rte_waypt(Waypoint* wpt);
+ void waypt_compute_bounds(bounds* bounds) const;
+ Waypoint* find_waypt_by_name(const QString& name) const;
+ void flush(); // a.k.a. clear()
+ void copy(WaypointList** dst) const;
+ void restore(WaypointList* src);
+ void swap(WaypointList& other);
+ void sort(Compare cmp);
+ template <typename T>
+ void waypt_disp_session(const session_t* se, T cb);
+
+ // Expose limited methods for portability.
+ // public types
+ using QList<Waypoint*>::const_iterator;
+ using QList<Waypoint*>::const_reverse_iterator;
+ using QList<Waypoint*>::iterator;
+ using QList<Waypoint*>::reverse_iterator;
+ // public functions
+ using QList<Waypoint*>::back; // a.k.a. last()
+ using QList<Waypoint*>::begin;
+ using QList<Waypoint*>::cbegin;
+ using QList<Waypoint*>::cend;
+ using QList<Waypoint*>::count; // a.k.a. size()
+ using QList<Waypoint*>::crbegin;
+ using QList<Waypoint*>::crend;
+ using QList<Waypoint*>::empty; // a.k.a. isEmpty()
+ using QList<Waypoint*>::end;
+ using QList<Waypoint*>::front; // a.k.a. first()
+ using QList<Waypoint*>::rbegin;
+ using QList<Waypoint*>::rend;
+};
+
const global_trait* get_traits();
void waypt_init();
//void update_common_traits(const Waypoint* wpt);
void waypt_add(Waypoint* wpt);
void waypt_del(Waypoint* wpt);
unsigned int waypt_count();
-void set_waypt_count(unsigned int nc);
void waypt_disp(const Waypoint* wpt);
void waypt_status_disp(int total_ct, int myct);
//void waypt_disp_all(waypt_cb); /* template */
void waypt_add_to_bounds(bounds* bounds, const Waypoint* waypointp);
void waypt_compute_bounds(bounds* bounds);
Waypoint* find_waypt_by_name(const QString& name);
-void waypt_flush(queue* head);
void waypt_flush_all();
-void waypt_backup(signed int* count, queue** head_bak);
-void waypt_restore(signed int count, queue* head_bak);
+void waypt_append(WaypointList* src);
+void waypt_backup(WaypointList** head_bak);
+void waypt_restore(WaypointList* head_bak);
+void waypt_swap(WaypointList& other);
+void waypt_sort(WaypointList::Compare cmp);
void waypt_add_url(Waypoint* wpt, const QString& link,
const QString& url_link_text);
void waypt_add_url(Waypoint* wpt, const QString& link,
template <typename T>
void
-waypt_disp_session(const session_t* se, T cb)
+WaypointList::waypt_disp_session(const session_t* se, T cb)
{
- extern queue waypt_head;
int i = 0;
-#if NEWQ
- foreach (Waypoint* waypointp, waypt_list) {
-#else
- queue* elem, *tmp;
- QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- Waypoint* waypointp = reinterpret_cast<Waypoint*>(elem);
-#endif
+ foreach (Waypoint* waypointp, *this) {
if ((se == nullptr) || (waypointp->session == se)) {
if (global_opts.verbose_status) {
i++;
}
}
+template <typename T>
+void
+waypt_disp_session(const session_t* se, T cb)
+{
+ extern WaypointList* global_waypoint_list;
+
+ global_waypoint_list->waypt_disp_session(se, cb);
+}
+
template <typename T>
void
waypt_disp_all(T cb)
{
- waypt_disp_session(nullptr, cb);
+ extern WaypointList* global_waypoint_list;
+
+ global_waypoint_list->waypt_disp_session(nullptr, cb);
}
/*
class route_head
{
public:
- queue waypoint_list; /* List of child waypoints */
+ WaypointList waypoint_list; /* List of child waypoints */
QString rte_name;
QString rte_desc;
UrlList rte_urls;
// Our contained element (route_head) also contains a container (waypoint_list),
// and we maintain a total count the elements in these contained containers, i.e.
// the total number of waypoints in all the routes in the RouteList.
+ // public types
+ using QList<route_head*>::const_iterator;
+ using QList<route_head*>::const_reverse_iterator;
+ using QList<route_head*>::iterator;
+ using QList<route_head*>::reverse_iterator;
+ // public functions
+ using QList<route_head*>::back; // a.k.a. last()
using QList<route_head*>::begin;
- using QList<route_head*>::end;
using QList<route_head*>::cbegin;
using QList<route_head*>::cend;
+ using QList<route_head*>::count; // a.k.a. size()
+ using QList<route_head*>::crbegin;
+ using QList<route_head*>::crend;
using QList<route_head*>::empty; // a.k.a. isEmpty()
+ using QList<route_head*>::end;
using QList<route_head*>::front; // a.k.a. first()
- using QList<route_head*>::back; // a.k.a. last()
- using QList<route_head*>::count; // a.k.a. size()
- using QList<route_head*>::iterator;
- using QList<route_head*>::const_iterator;
- typedef iterator Iterator;
- typedef const_iterator ConstIterator;
+ using QList<route_head*>::rbegin;
+ using QList<route_head*>::rend;
private:
int waypt_ct{0};
void
route_disp(const route_head* rh, T cb)
{
- queue* elem, *tmp;
// cb != nullptr, caught with an overload of route_disp
- QUEUE_FOR_EACH(&rh->waypoint_list, elem, tmp) {
- Waypoint* waypointp;
- waypointp = reinterpret_cast<Waypoint*>(elem);
+ foreach (const Waypoint* waypointp, rh->waypoint_list) {
cb(waypointp);
}
}
*/
-#include <QtCore/QXmlStreamAttributes>
+#include <cstdio> // for SEEK_CUR, size_t
+#include <cstdint> // int32_t, int16_t, uint32_t
+#include <cstdlib> // for atoi
+#include <cstring> // for strncmp, memcpy, strcmp, strlen
+
+#include <QtCore/QByteArray> // for QByteArray
+#include <QtCore/QString> // for QString, operator+
+#include <QtCore/QXmlStreamAttributes> // for QXmlStreamAttributes
+#include <QtCore/QtGlobal> // for qPrintable
#include "defs.h"
-#include "jeeps/gpsmath.h"
-#include "xmlgeneric.h"
+#include "gbfile.h" // for gbfgetdbl, gbfgetint32, gbfputint32, gbfgetint16, gbfputdbl, gbfputc, gbfread, gbfseek, gbfgetc, gbfile, gbfclose, gbfungetc, gbfeof, gbfputs, gbfwrite, gbfopen_le, gbfgetuint32, gbfputuint16, gbfputuint32
+#include "jeeps/gpsmath.h" // for GPS_Lookup_Datum_Index, GPS_Math_Known_Datum_To_WGS84_C, GPS_Math_NGENToAiry1830LatLon
+#include "xmlgeneric.h" // for cb_cdata, xg_callback, xg_string, xml_deinit, xml_init, cb_end, cb_start, xg_cb_type, xml_read, xml_readstring, xg_tag_mapping
+
#define MYNAME "dmtlog"
int count = 0;
if (trk != nullptr) {
- queue* curr, *prev;
- QUEUE_FOR_EACH(&trk->waypoint_list, curr, prev) count++;
+ count = trk->waypoint_list.count();
}
if (!trk || trk->rte_name.isEmpty()) {
write_str("Name", fout);
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
*/
+
+#include <cstdio> // for sprintf
+#include <cstdlib> // for qsort
+#include <cstring> // for memset, strncpy
+
+#include <QtCore/QDateTime> // for QDateTime
+#include <QtCore/QtGlobal> // for foreach
+
#include "defs.h"
-#include "duplicate.h"
#include "filterdefs.h"
-#include <cstdio>
-#include <cstdlib> // qsort
+#include "duplicate.h"
+#include "src/core/datetime.h" // for DateTime
+
#if FILTERS_ENABLED
Waypoint* delwpt = nullptr;
int ct = waypt_count();
- queue* elem, *tmp;
wpt_ptr* htable = (wpt_ptr*) xmalloc(ct * sizeof(*htable));
wpt_ptr* bh = htable;
int i = 0;
-#if NEWQ
- foreach (Waypoint* waypointp, waypt_list) {
+ foreach (Waypoint* waypointp, *global_waypoint_list) {
bh->wpt = waypointp;
-#else
- QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- bh->wpt = reinterpret_cast<Waypoint *>(elem);
-#endif
bh->index = i;
i ++;
bh ++;
#ifndef FILTERDEFS_H_INCLUDED_
#define FILTERDEFS_H_INCLUDED_
-#if NEWQ
-#include <QtCore/QList>
-extern QList<Waypoint*> waypt_list;
-#else
-#include "queue.h"
-extern queue waypt_head;
-#endif
+#include "defs.h"
#include "filter.h"
+extern WaypointList* global_waypoint_list;
+
typedef void (*filter_init)();
typedef void (*filter_process)();
typedef void (*filter_deinit)();
*/
-#include <cctype>
-#include <climits>
-#include <cmath>
-#include <cstdlib>
+#include <cctype> // for isalpha, toupper
+#include <climits> // for INT_MAX
+#include <cmath> // for atan2, floor, sqrt
+#include <csetjmp> // for setjmp
+#include <cstdio> // for fprintf, fflush, snprintf, sprintf
+#include <cstdlib> // for atoi, strtol
+#include <cstring> // for memcpy, strlen, strncpy, strchr
+#include <ctime> // for time_t
+
+#include <QtCore/QByteArray> // for QByteArray
+#include <QtCore/QChar> // for QChar
+#include <QtCore/QString> // for QString
+#include <QtCore/Qt> // for CaseInsensitive
+#include <QtCore/QtGlobal> // for qPrintable, foreach
-#include "cet_util.h"
#include "defs.h"
-#include "garmin_device_xml.h"
-#include "garmin_fs.h"
-#include "garmin_tables.h"
-#include "grtcirc.h"
+#include "cet_util.h" // for cet_convert_init, cet_cs_vec_utf8
+#include "garmin_device_xml.h" // for gdx_get_info, gdx_info, gdx_file, gdx_jmp_buf
+#include "garmin_fs.h" // for garmin_fs_garmin_after_read, garmin_fs_garmin_before_write
+#include "garmin_tables.h" // for gt_find_icon_number_from_desc, PCX, gt_find_desc_from_icon_number
+#include "grtcirc.h" // for DEG
#include "jeeps/gps.h"
#include "jeeps/gpsserial.h"
+#include "src/core/datetime.h" // for DateTime
#define MYNAME "GARMIN"
static const char* portname;
{
int i;
int n = waypt_count();
-#if NEWQ
- extern QList<Waypoint*> waypt_list;
-#else
- queue* elem, *tmp;
- extern queue waypt_head;
-#endif
+ extern WaypointList* global_waypoint_list;
int icon;
tx_waylist = (struct GPS_SWay**) xcalloc(n,sizeof(*tx_waylist));
i = 0;
-#if NEWQ
// Iterate with waypt_disp_all?
- foreach(Waypoint* wpt, waypt_list) {
-#else
- QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- Waypoint* wpt = reinterpret_cast<Waypoint *>(elem);
-#endif
+ foreach(Waypoint* wpt, *global_waypoint_list) {
char obuf[256];
QString src;
#include <cstdlib> // for atoi, strtol, NULL
#include <cstring> // for memset, strcmp, strstr, strchr, strlen, strncpy
#include <ctime> // for strftime
+#include <iterator> // for next
#include <QtCore/QByteArray> // for QByteArray
#include <QtCore/QList> // for QList
#include "gbfile.h" // for gbfputint32, gbfgetint32, gbfread, gbfwrite, gbfgetc, gbfputc, gbfgetdbl, gbfgetcstr, gbfile, gbfclose, gbfputcstr, gbfcopyfrom, gbfrewind, gbfseek, gbftell, gbfopen_le, gbfgetcstr_old, gbfgetint16, gbfputdbl, gbfputint16
#include "grtcirc.h" // for RAD, gcdist, radtometers
#include "jeeps/gpsmath.h" // for GPS_Math_Deg_To_Semi, GPS_Math_Semi_To_Deg
-#include "queue.h" // for queue, QUEUE_FOR_EACH
#include "src/core/datetime.h" // for DateTime
static void
route_compute_bounds(const route_head* rte, bounds* bounds)
{
- queue* elem, *tmp;
waypt_init_bounds(bounds);
- QUEUE_FOR_EACH((queue*)&rte->waypoint_list, elem, tmp) {
- Waypoint* wpt = reinterpret_cast<Waypoint *>(elem);
+ foreach (Waypoint* wpt, rte->waypoint_list) {
gdb_check_waypt(wpt);
waypt_add_to_bounds(bounds, wpt);
}
write_route(const route_head* rte, const QString& rte_name)
{
bounds bounds;
- queue* elem, *tmp;
char zbuf[32], ffbuf[32];
memset(zbuf, 0, sizeof(zbuf));
int index = 0;
- QUEUE_FOR_EACH((queue*)&rte->waypoint_list, elem, tmp) {
+ for (auto it =rte->waypoint_list.cbegin(); it != rte->waypoint_list.cend(); ++it) {
- Waypoint* wpt = reinterpret_cast<Waypoint *>(elem);
- Waypoint* next = reinterpret_cast<Waypoint *>(tmp);
+ Waypoint* wpt = *it;
+ Waypoint* next = nullptr;
+ if (index < points) {
+ next = *std::next(it);
+ }
index++;
rtept_ct++; /* increase informational number of written route points */
static void
write_track(const route_head* trk, const QString& trk_name)
{
- queue* elem, *tmp;
int points = ELEMENTS(trk);
FWRITE_CSTR(trk_name);
FWRITE_i32(points); /* total number of waypoints in waypoint list */
- QUEUE_FOR_EACH((queue*)&trk->waypoint_list, elem, tmp) {
- Waypoint* wpt = reinterpret_cast<Waypoint *>(elem);
+ foreach (const Waypoint* wpt, trk->waypoint_list) {
trkpt_ct++; /* increase informational number of written route points */
*/
-#include <cctype>
-#include <cmath>
-#include <cstdio>
-#include <ctime>
+#include <cmath> // for fabs, floor, lround
+#include <cstdio> // for sscanf
+#include <cstring> // for memset, strncmp
+#include <cstdint> // for int16_t
+#include <ctime> // for gmtime
+
+#include <QtCore/QString> // for QString
+#include <QtCore/QTime> // for QTime
+#include <QtCore/QtGlobal> // for foreach
#include "defs.h"
-#include "grtcirc.h"
-#include "jeeps/gpsmath.h"
+#include "gbfile.h" // for gbfputint16, gbfclose, gbfopen, gbfputflt, gbfgetc, gbfputcstr, gbfputdbl, gbfread, gbfile
+#include "grtcirc.h" // for heading_true_degrees
+#include "src/core/datetime.h" // for DateTime
+
+
#define MYNAME "ggv_log"
static void
ggv_log_track_head_cb(const route_head* trk)
{
- queue* elem, *tmp;
- Waypoint* prev = nullptr;
+ const Waypoint* prev = nullptr;
- QUEUE_FOR_EACH((queue*)&trk->waypoint_list, elem, tmp) {
+ foreach (const Waypoint* wpt, trk->waypoint_list) {
double course = 0, speed = 0;
struct tm tm;
- Waypoint* wpt = reinterpret_cast<Waypoint *>(elem);
double secs = 0;
int latint = wpt->latitude;
*/
+#include <cmath> // for sin, cos, acos
+#include <cstdio> // for snprintf
+
+#include <QtCore/QString> // for QString
+#include <QtCore/QtGlobal> // for foreach
+
#include "defs.h"
-#include "grtcirc.h"
-#include "inifile.h"
+#include "gbfile.h" // for gbfprintf, gbfclose, gbfopen, gbfile
+#include "grtcirc.h" // for RAD, gcdist, DEG
+#include "inifile.h" // for inifile_readstr, inifile_readint_def, inifile_done, inifile_init, inifile_readint, inifile_t
-#include <QtCore/QString>
-#include <cmath>
-#include <cstdio>
-#include <cstdlib>
#define MYNAME "ggv_ovl"
static void
track_disp_cb(const route_head* trk)
{
- queue* elem, *tmp;
int waypt_ct = trk->rte_waypt_ct;
if (waypt_ct <= 0) {
int i = 0;
- QUEUE_FOR_EACH(&(trk->waypoint_list), elem, tmp) {
-
- Waypoint* wpt = reinterpret_cast<Waypoint *>(elem);
+ foreach (const Waypoint* wpt, trk->waypoint_list) {
gbfprintf(fout, "XKoord%d=%0.8f\n", i, wpt->longitude);
gbfprintf(fout, "YKoord%d=%0.8f\n", i, wpt->latitude);
static void
route_disp_cb(const route_head* rte)
{
- queue* elem, *tmp;
int waypt_ct = rte->rte_waypt_ct;
if (waypt_ct <= 0) {
color = OVL_COLOR_RED;
int i = 0;
- Waypoint* prev = nullptr;
-
- QUEUE_FOR_EACH(&(rte->waypoint_list), elem, tmp) {
+ const Waypoint* prev = nullptr;
- Waypoint* wpt = reinterpret_cast<Waypoint *>(elem);
+ foreach (const Waypoint* wpt, rte->waypoint_list) {
if (prev != nullptr) {
draw_symbol_basics(OVL_SYMBOL_TRIANGLE, 1, (OVL_COLOR_TYP)9 /* color */, prev);
*/
+#include <cmath> // for lround
+#include <cstdio> // for sscanf
+#include <cstdlib> // for atoi, strtod
+#include <cstring> // for strchr, strncpy
+
+#include <QtCore/QDate> // for QDate
+#include <QtCore/QDateTime> // for QDateTime
+#include <QtCore/QHash> // for QHash
+#include <QtCore/QIODevice> // for QIODevice, operator|, QIODevice::ReadOnly, QIODevice::Text, QIODevice::WriteOnly
+#include <QtCore/QLatin1String> // for QLatin1String
+#include <QtCore/QStaticStringData> // for QStaticStringData
+#include <QtCore/QString> // for QString, QStringLiteral, operator+, operator==
+#include <QtCore/QStringList> // for QStringList
+#include <QtCore/QStringRef> // for QStringRef
+#include <QtCore/QTime> // for QTime
+#include <QtCore/QVector> // for QVector
+#include <QtCore/QXmlStreamAttribute> // for QXmlStreamAttribute
+#include <QtCore/QXmlStreamAttributes> // for QXmlStreamAttributes
+#include <QtCore/QXmlStreamNamespaceDeclaration> // for QXmlStreamNamespaceDeclaration
+#include <QtCore/QXmlStreamNamespaceDeclarations> // for QXmlStreamNamespaceDeclarations
+#include <QtCore/QXmlStreamReader> // for QXmlStreamReader, QXmlStreamReader::Characters, QXmlStreamReader::EndDocument, QXmlStreamReader::EndElement, QXmlStreamReader::Invalid, QXmlStreamReader::StartElement
+#include <QtCore/Qt> // for CaseInsensitive, UTC
+#include <QtCore/QtGlobal> // for qAsConst, QAddConst<>::Type
+
#include "defs.h"
#include "garmin_fs.h"
#include "garmin_tables.h"
#include "src/core/xmlstreamwriter.h"
#include "src/core/xmltag.h"
-#include <QtCore/QDateTime> // for QDateTime, QDate, QTime
-#include <QtCore/QHash> // for QHash
-#include <QtCore/QList> // for QList
-#include <QtCore/QString> // for QString, QStringLiteral, QStringRef, QStaticStringData, QLatin1String, operator+
-#include <QtCore/QStringList> // for QStringList
-#include <QtCore/QXmlStreamAttributes> // for QXmlStreamAttributes
-#include <QtCore/QXmlStreamNamespaceDeclarations> // for QXmlStreamNamespaceDeclarations
-#include <QtCore/QXmlStreamReader> // for QXmlStreamReader, QXmlStreamReader::TokenType::Characters, QXmlStreamReader::TokenType::EndDocument, QXmlStreamReader::TokenType::EndElement, QXmlStreamReader::TokenType::Invalid, QXmlStreamReader::TokenType::StartElement
-#include <QtCore/QtGlobal> // for qAsConst
-
-#include <cmath> // for lround
-#include <cstdio> // for sscanf
-#include <cstdlib> // for atoi, strtod
-#include <cstring> // for strchr
-
static QXmlStreamReader* reader;
static xml_tag* cur_tag;
static void
gpx_track_disp(const Waypoint* waypointp)
{
- bool first_in_trk = waypointp->Q.prev == ¤t_trk_head->waypoint_list;
+ bool first_in_trk = waypointp == current_trk_head->waypoint_list.front();
if (waypointp->wpt_flags.new_trkseg) {
if (!first_in_trk) {
static void
gpx_track_tlr(const route_head*)
{
- if (!QUEUE_EMPTY(¤t_trk_head->waypoint_list)) {
+ if (!current_trk_head->waypoint_list.empty()) {
writer->writeEndElement();
}
* 59 Temple Place - Suite 330, Boston, MA 02111 USA
*/
+#include <cmath> // for fabs, lround
+#include <cstdio> // for sscanf, snprintf, fputs, printf, stdout, putchar, size_t
+#include <cstdlib> // for labs, ldiv, ldiv_t, abs
+#include <cstring> // for strcmp, strlen, strtok, strcat, strchr, strcpy, strncat
+#include <ctime> // for gmtime, ctime
+#include <iterator> // for reverse_iterator, operator==, prev, next
+
+#include <QtCore/QByteArray> // for QByteArray
+#include <QtCore/QList> // for QList<>::const_iterator
+#include <QtCore/QStaticStringData> // for QStaticStringData
+#include <QtCore/QString> // for QString, operator+, QStringLiteral
+#include <QtCore/QtGlobal> // for foreach, qPrintable
+
#include "defs.h"
-#include "cet_util.h"
-#include <cerrno>
-#include <cmath>
-#include <cstdio>
-#include <cstdlib>
+#include "cet_util.h" // for cet_convert_init
+#include "gbfile.h" // for gbfprintf, gbfclose, gbfopen, gbfputs, gbfgetstr, gbfile
+#include "src/core/datetime.h" // for DateTime
+#include "src/core/optional.h" // for optional
+
static gbfile* file_in, *file_out;
static char manufacturer[4];
}
// Date in header record is that of the first fix record
date = !track ? current_time().toTime_t() :
- (reinterpret_cast<Waypoint *>QUEUE_FIRST(&track->waypoint_list))->GetCreationTime().toTime_t();
+ track->waypoint_list.front()->GetCreationTime().toTime_t();
if (nullptr == (tm = gmtime(&date))) {
fatal(MYNAME ": Bad track timestamp\n");
}
// See if the takeoff and landing waypoints are there or if we need to
// generate them.
- const Waypoint* wpt = reinterpret_cast<Waypoint *>QUEUE_LAST(&rte->waypoint_list);
+ const Waypoint* wpt = rte->waypoint_list.back();
if (wpt->shortname.startsWith("LANDING")) {
num_tps--;
}
- wpt = reinterpret_cast<Waypoint *>QUEUE_FIRST(&rte->waypoint_list);
+ wpt = rte->waypoint_list.front();
if (wpt->shortname.startsWith("TAKEOFF")) {
have_takeoff = 1;
num_tps--;
static void wr_task_tlr(const route_head* rte)
{
// If the landing waypoint is not supplied we need to generate it.
- const Waypoint* wpt = reinterpret_cast<Waypoint *>QUEUE_LAST(&rte->waypoint_list);
+ const Waypoint* wpt = rte->waypoint_list.back();
QString sn = wpt->shortname;
// if (!wpt->shortname || strncmp(wpt->shortname, "LANDIN", 6) != 0) {
if (sn.isEmpty() || !sn.startsWith("LANDIN")) {
// Deduce the landing time from the pressure altitude track based on
// when we last descended to within 10m of the final track altitude.
- const queue* elem = QUEUE_LAST(&pres_track->waypoint_list);
- double last_alt = (reinterpret_cast<const Waypoint *>(elem))->altitude;
+ WaypointList::const_reverse_iterator wpt_rit = pres_track->waypoint_list.crbegin();
+ double last_alt = (*wpt_rit)->altitude;
do {
- elem = elem->prev;
- if (&pres_track->waypoint_list == elem) {
+ ++wpt_rit;
+ if (pres_track->waypoint_list.crend() == wpt_rit) {
// No track left
return 0;
}
- alt_diff = last_alt - (reinterpret_cast<const Waypoint *>(elem))->altitude;
+ alt_diff = last_alt - (*wpt_rit)->altitude;
if (alt_diff > 10.0) {
// Last part of track was ascending
return 0;
}
} while (alt_diff > -10.0);
- pres_time = (reinterpret_cast<Waypoint *>(elem->next))->GetCreationTime().toTime_t();
+ pres_time = (*std::prev(wpt_rit))->GetCreationTime().toTime_t();
if (global_opts.debug_level >= 1) {
printf(MYNAME ": pressure landing time %s", ctime(&pres_time));
}
+
// Deduce the landing time from the GNSS altitude track based on
// when the groundspeed last dropped below a certain level.
- elem = QUEUE_LAST(&gnss_track->waypoint_list);
- last_alt = (reinterpret_cast<const Waypoint *>(elem))->altitude;
+ wpt_rit = gnss_track->waypoint_list.crbegin();
do {
- const Waypoint* wpt = reinterpret_cast<const Waypoint *>(elem);
- elem = elem->prev;
- if (&gnss_track->waypoint_list == elem) {
+ const Waypoint* wpt = *wpt_rit;
+ ++wpt_rit;
+ if (gnss_track->waypoint_list.crend() == wpt_rit) {
// No track left
return 0;
}
// Get a crude indication of groundspeed from the change in lat/lon
- time_diff = wpt->GetCreationTime().toTime_t() - (reinterpret_cast<const Waypoint *>(elem))->GetCreationTime().toTime_t();
+ time_diff = wpt->GetCreationTime().toTime_t() - (*wpt_rit)->GetCreationTime().toTime_t();
speed = !time_diff ? 0 :
- (fabs(wpt->latitude - (reinterpret_cast<const Waypoint *>(elem))->latitude) +
- fabs(wpt->longitude - (reinterpret_cast<const Waypoint *>(elem))->longitude)) / time_diff;
+ (fabs(wpt->latitude - (*wpt_rit)->latitude) +
+ fabs(wpt->longitude - (*wpt_rit)->longitude)) / time_diff;
if (global_opts.debug_level >= 2) {
printf(MYNAME ": speed=%f\n", speed);
}
} while (speed < 0.00003);
- gnss_time = (reinterpret_cast<Waypoint *>(elem->next))->GetCreationTime().toTime_t();
+ gnss_time = (*std::prev(wpt_rit))->GetCreationTime().toTime_t();
if (global_opts.debug_level >= 1) {
printf(MYNAME ": gnss landing time %s", ctime(&gnss_time));
}
*/
static double interpolate_alt(const route_head* track, time_t time)
{
- static const queue* prev_elem = nullptr;
- static const queue* curr_elem = nullptr;
+ static gpsbabel_optional::optional<WaypointList::const_iterator> prev_wpt;
+ static gpsbabel_optional::optional<WaypointList::const_iterator> curr_wpt;
int time_diff;
// Start search at the beginning of the track
- if (!prev_elem) {
- curr_elem = prev_elem = QUEUE_FIRST(&track->waypoint_list);
+ if (!prev_wpt.has_value()) {
+ prev_wpt = track->waypoint_list.cbegin();
+ curr_wpt = track->waypoint_list.cbegin();
}
// Find the track points either side of the requested time
- while ((reinterpret_cast<const Waypoint *>(curr_elem))->GetCreationTime().toTime_t() < time) {
- if (QUEUE_LAST(&track->waypoint_list) == curr_elem) {
- // Requested time later than all track points, we can't interpolate
- return unknown_alt;
- }
- prev_elem = curr_elem;
- curr_elem = QUEUE_NEXT(prev_elem);
+ while ((track->waypoint_list.cend() != curr_wpt.value()) &&
+ ((*curr_wpt.value())->GetCreationTime().toTime_t() < time)) {
+ prev_wpt = curr_wpt.value();
+ curr_wpt = std::next(prev_wpt.value());
+ }
+ if (track->waypoint_list.cend() == curr_wpt.value()) {
+ // Requested time later than all track points, we can't interpolate
+ return unknown_alt;
}
- const Waypoint* prev_wpt = reinterpret_cast<const Waypoint *>(prev_elem);
- const Waypoint* curr_wpt = reinterpret_cast<const Waypoint *>(curr_elem);
-
- if (QUEUE_FIRST(&track->waypoint_list) == curr_elem) {
- if (curr_wpt->GetCreationTime().toTime_t() == time) {
+ if (track->waypoint_list.cbegin() == curr_wpt.value()) {
+ if ((*curr_wpt.value())->GetCreationTime().toTime_t() == time) {
// First point's creation time is an exact match so use it's altitude
- return curr_wpt->altitude;
+ return (*curr_wpt.value())->altitude;
} else {
// Requested time is prior to any track points, we can't interpolate
return unknown_alt;
}
}
// Interpolate
- if (0 == (time_diff = curr_wpt->GetCreationTime().toTime_t() - prev_wpt->GetCreationTime().toTime_t())) {
+ if (0 == (time_diff = (*curr_wpt.value())->GetCreationTime().toTime_t() - (*prev_wpt.value())->GetCreationTime().toTime_t())) {
// Avoid divide by zero
- return curr_wpt->altitude;
+ return (*curr_wpt.value())->altitude;
}
- double alt_diff = curr_wpt->altitude - prev_wpt->altitude;
- return prev_wpt->altitude + (alt_diff / time_diff) * (time - prev_wpt->GetCreationTime().toTime_t());
+ double alt_diff = (*curr_wpt.value())->altitude - (*prev_wpt.value())->altitude;
+ return (*prev_wpt.value())->altitude + (alt_diff / time_diff) * (time - (*prev_wpt.value())->GetCreationTime().toTime_t());
}
/*
printf(MYNAME ": adjusting time by %ds\n", time_adj);
}
// Iterate through waypoints in both tracks simultaneously
- const queue* elem;
- const queue* tmp;
- QUEUE_FOR_EACH(&gnss_track->waypoint_list, elem, tmp) {
- // FIXME(NEW_Q): the excessive casting of the iterators is gross. Rethink.
- const Waypoint* wpt = reinterpret_cast<const Waypoint*>(elem);
+ foreach (const Waypoint* wpt, gnss_track->waypoint_list) {
double pres_alt = interpolate_alt(pres_track, wpt->GetCreationTime().toTime_t() + time_adj);
wr_fix_record(wpt, pres_alt, wpt->altitude);
}
if (pres_track) {
// Only the pressure altitude track was found so generate fix
// records from it alone.
- const queue* elem;
- const queue* tmp;
- QUEUE_FOR_EACH(&pres_track->waypoint_list, elem, tmp) {
- const Waypoint* wpt = reinterpret_cast<const Waypoint*>(elem);
+ foreach (const Waypoint* wpt, pres_track->waypoint_list) {
wr_fix_record(wpt, wpt->altitude, unknown_alt);
}
} else if (gnss_track) {
// Only the GNSS altitude track was found so generate fix
// records from it alone.
- const queue* elem;
- const queue* tmp;
- QUEUE_FOR_EACH(&gnss_track->waypoint_list, elem, tmp) {
- const Waypoint* wpt = reinterpret_cast<const Waypoint*>(elem);
+ foreach (const Waypoint* wpt, gnss_track->waypoint_list) {
wr_fix_record(wpt, unknown_alt, wpt->altitude);
}
} else {
*/
+#include <cstdlib> // for atoi, strtod
+
+#include <QtCore/QString> // for QString
+#include <QtCore/QtGlobal> // for qAsConst, QAddConst<>::Type, foreach
+
#include "defs.h"
#include "filterdefs.h"
-#include "grtcirc.h"
#include "interpolate.h"
-#include <cstdlib>
+#include "grtcirc.h" // for linepart, RAD, gcdist, radtomiles
+#include "src/core/datetime.h" // for DateTime
+
#if FILTERS_ENABLED
#define MYNAME "Interpolate filter"
void InterpolateFilter::process()
{
RouteList* backuproute = nullptr;
- queue* elem2, *tmp2;
double lat1 = 0, lon1 = 0;
double altitude1 = unknown_alt;
unsigned int time1 = 0;
fatal(MYNAME ": Found no routes or tracks to operate on.\n");
}
- for (auto it = backuproute->cbegin(); it != backuproute->cend(); ++it) {
- auto rte_old = reinterpret_cast<const route_head*>(*it);
+ for (const auto* rte_old : qAsConst(*backuproute)) {
route_head* rte_new = route_head_alloc();
rte_new->rte_name = rte_old->rte_name;
track_add_head(rte_new);
}
bool first = true;
- QUEUE_FOR_EACH(&rte_old->waypoint_list, elem2, tmp2) {
- Waypoint* wpt = reinterpret_cast<Waypoint *>(elem2);
+ foreach (const Waypoint* wpt, rte_old->waypoint_list) {
if (first) {
first = false;
} else {
# include <windows.h>
#endif
-#include "defs.h"
-#include "grtcirc.h"
-#include "queue.h"
-#include "src/core/datetime.h"
-#include "src/core/file.h"
-#include "src/core/xmlstreamwriter.h"
-#include "src/core/xmltag.h"
-#include "xmlgeneric.h"
-#include <QtCore/QXmlStreamAttributes> // for QXmlStreamAttributes
+#include <cctype> // for tolower, toupper
+#include <cmath> // for fabs
+#include <cstdio> // for sscanf, printf
+#include <cstdlib> // for atoi, atol, atof
+#include <cstring> // for strcmp
+#include <tuple> // for tuple, make_tuple, tie
+
+#include <QtCore/QByteArray> // for QByteArray
+#include <QtCore/QChar> // for QChar
+#include <QtCore/QDate> // for QDate
#include <QtCore/QDateTime> // for QDateTime
#include <QtCore/QFile> // for QFile
+#include <QtCore/QIODevice> // for operator|, QIODevice, QIODevice::Text, QIODevice::WriteOnly
#include <QtCore/QList> // for QList
-#include <QtCore/QString> // for QString, QStringLiteral, QStat...
-#include <QtCore/QtGlobal> // for qint64, qPrintable
-#include <cctype>
-#include <cmath>
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <tuple>
+#include <QtCore/QStaticStringData> // for QStaticStringData
+#include <QtCore/QString> // for QString, QStringLiteral, operator+, operator!=
+#include <QtCore/QXmlStreamAttributes> // for QXmlStreamAttributes
+#include <QtCore/Qt> // for ISODate
+#include <QtCore/QtGlobal> // for foreach, qint64, qPrintable
+
+#include "defs.h"
+#include "grtcirc.h" // for RAD, gcdist, radtometers
+#include "src/core/datetime.h" // for DateTime
+#include "src/core/file.h" // for File
+#include "src/core/optional.h" // for optional
+#include "src/core/xmlstreamwriter.h" // for XmlStreamWriter
+#include "src/core/xmltag.h" // for xml_findfirst, xml_tag, fs_xml, xml_attribute, xml_findnext
+#include "xmlgeneric.h" // for cb_cdata, cb_end, cb_start, xg_callback, xg_string, xg_cb_type, xml_deinit, xml_ignore_tags, xml_init, xml_read, xg_tag_mapping
+
// options
static char* opt_deficon = nullptr;
if (trk_head->rte_waypt_ct > 0) {
qint64 timespan_ms = wpt_timespan_begin.msecsTo(wpt_timespan_end);
qint64 ms_per_waypoint = timespan_ms / trk_head->rte_waypt_ct;
- queue* curr_elem;
- queue* tmp_elem;
- QUEUE_FOR_EACH(&trk_head->waypoint_list, curr_elem, tmp_elem) {
- trkpt = reinterpret_cast<Waypoint*>(curr_elem);
+ foreach (Waypoint* trkpt, trk_head->waypoint_list) {
trkpt->SetCreationTime(wpt_timespan_begin);
wpt_timespan_begin = wpt_timespan_begin.addMSecs(ms_per_waypoint);
}
// Add a linestring for this track?
if (export_lines && header->rte_waypt_ct > 0) {
int needs_multigeometry = 0;
- queue* elem, *tmp;
- QUEUE_FOR_EACH(&header->waypoint_list, elem, tmp) {
- Waypoint* tpt = reinterpret_cast<Waypoint*>(elem);
- int first_in_trk = tpt->Q.prev == &header->waypoint_list;
+ foreach (const Waypoint* tpt, header->waypoint_list) {
+ int first_in_trk = tpt == header->waypoint_list.front();
if (!first_in_trk && tpt->wpt_flags.new_trkseg) {
needs_multigeometry = 1;
break;
writer->writeStartElement(QStringLiteral("MultiGeometry"));
}
- QUEUE_FOR_EACH(&header->waypoint_list, elem, tmp) {
- Waypoint* tpt = reinterpret_cast<Waypoint*>(elem);
- int first_in_trk = tpt->Q.prev == &header->waypoint_list;
+ foreach (const Waypoint* tpt, header->waypoint_list) {
+ int first_in_trk = tpt == header->waypoint_list.front();
if (tpt->wpt_flags.new_trkseg) {
if (!first_in_trk) {
writer->writeEndElement(); // Close coordinates tag
const char* name,
wp_field member)
{
- queue* elem, *tmp;
writer->writeStartElement(QStringLiteral("gx:SimpleArrayData"));
writer->writeAttribute(QStringLiteral("name"), name);
- QUEUE_FOR_EACH(&header->waypoint_list, elem, tmp) {
-
- Waypoint* wpt = reinterpret_cast<Waypoint*>(elem);
+ foreach (const Waypoint* wpt, header->waypoint_list) {
switch (member) {
case fld_power:
// True if at least two points in the track have timestamps.
static int track_has_time(const route_head* header)
{
- queue* elem, *tmp;
int points_with_time = 0;
- QUEUE_FOR_EACH(&header->waypoint_list, elem, tmp) {
- Waypoint* tpt = reinterpret_cast<Waypoint*>(elem);
-
+ foreach (const Waypoint* tpt, header->waypoint_list) {
if (tpt->GetCreationTime().isValid()) {
points_with_time++;
if (points_with_time >= 2) {
// Simulate a track_disp_all callback sequence for a single track.
static void write_as_linestring(const route_head* header)
{
- queue* elem, *tmp;
kml_track_hdr(header);
- QUEUE_FOR_EACH(&header->waypoint_list, elem, tmp) {
- Waypoint* tpt = reinterpret_cast<Waypoint*>(elem);
+ foreach (const Waypoint* tpt, header->waypoint_list) {
kml_track_disp(tpt);
}
kml_track_tlr(header);
static void kml_mt_hdr(const route_head* header)
{
- queue* elem, *tmp;
int has_cadence = 0;
int has_depth = 0;
int has_heartrate = 0;
writer->writeStartElement(QStringLiteral("gx:Track"));
kml_output_positioning(false);
- QUEUE_FOR_EACH(&header->waypoint_list, elem, tmp) {
- Waypoint* tpt = reinterpret_cast<Waypoint*>(elem);
-
+ foreach (const Waypoint* tpt, header->waypoint_list) {
if (tpt->GetCreationTime().isValid()) {
QString time_string = tpt->CreationTimeXML();
writer->writeOptionalTextElement(QStringLiteral("when"), time_string);
}
// TODO: How to handle clamped, floating, extruded, etc.?
- QUEUE_FOR_EACH(&header->waypoint_list, elem, tmp) {
- Waypoint* tpt = reinterpret_cast<Waypoint*>(elem);
-
+ foreach (const Waypoint* tpt, header->waypoint_list) {
if (kml_altitude_known(tpt)) {
writer->writeTextElement(QStringLiteral("gx:coord"),
QString::number(tpt->longitude, 'f', precision) + QString(" ") +
track points if we've not moved a minimum distance from the
beginning of our accumulated track. */
{
- Waypoint* newest_posn= reinterpret_cast<Waypoint*>QUEUE_LAST(&posn_trk_head->waypoint_list);
+ Waypoint* newest_posn= posn_trk_head->waypoint_list.back();
if (radtometers(gcdist(RAD(wpt->latitude), RAD(wpt->longitude),
RAD(newest_posn->latitude), RAD(newest_posn->longitude))) > 50) {
*/
while (max_position_points &&
(posn_trk_head->rte_waypt_ct >= max_position_points)) {
- Waypoint* tonuke = reinterpret_cast<Waypoint*>QUEUE_FIRST(&posn_trk_head->waypoint_list);
+ Waypoint* tonuke = posn_trk_head->waypoint_list.front();
track_del_wpt(posn_trk_head, tonuke);
}
*/
+#include <cmath> // for M_PI, atan, exp, log, tan
+#include <cstdio> // for printf, snprintf, sprintf, SEEK_CUR
+#include <cstdlib> // for atoi, abs
+#include <cstring> // for strlen, strcmp
+#include <ctime>
+
+#include <QtCore/QByteArray> // for QByteArray
+#include <QtCore/QDate> // for QDate
+#include <QtCore/QDateTime> // for QDateTime
+#include <QtCore/QLatin1String> // for QLatin1String
+#include <QtCore/QString> // for QString, operator+, operator==, operator!=
+#include <QtCore/QTextCodec> // for QTextCodec
+#include <QtCore/QTime> // for QTime
+#include <QtCore/Qt> // for CaseInsensitive, UTC
+#include <QtCore/QtGlobal> // for qPrintable, uint, foreach
#include "defs.h"
-#include "src/core/datetime.h"
-#include <QtCore/QByteArray>
-#include <QtCore/QDate>
-#include <QtCore/QDateTime>
-#include <QtCore/QTime>
-#include <QtCore/QTextCodec>
-#include <QtCore/QDebug>
-#include <cmath> // for lat/lon conversion
-#include <cstdio> // for gmtime
-#include <cstdlib> // atoi
+#include "gbfile.h" // for gbfgetint32, gbfputint32, gbfputint16, gbfgetc, gbfgetint16, gbfputc, gbfwrite, gbfeof, gbfgetflt, gbfclose, gbfgetdbl, gbfputdbl, gbfile, gbfputflt, gbfread, gbfseek, gbfopen_le
+#include "src/core/datetime.h" // for DateTime
+
typedef struct lowranceusr_icon_mapping {
const int value;
static int waypt_table_ct;
/* from waypt.c, we need to iterate over waypoints when extracting routes */
-#if NEWQ
-extern QList<Waypoint*> waypt_list;
-#else
-extern queue waypt_head;
-#endif
+extern WaypointList* global_waypoint_list;
static unsigned short waypt_out_count;
static int trail_count, lowrance_route_count;
static Waypoint*
lowranceusr4_find_waypt(uint uid_unit, int uid_seq_low, int uid_seq_high)
{
-#if !NEWQ
- queue* elem, *tmp;
-#endif
lowranceusr4_fsdata* fs = nullptr;
-#if NEWQ
// Iterate with waypt_disp_all?
- foreach (Waypoint* waypointp, waypt_list) {
-#else
- QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- Waypoint* waypointp = reinterpret_cast<Waypoint*>(elem);
-#endif
+ foreach (Waypoint* waypointp, *global_waypoint_list) {
fs = (lowranceusr4_fsdata*) fs_chain_find(waypointp->fs, FS_LOWRANCEUSR4);
if (fs && fs->uid_unit == uid_unit &&
static Waypoint*
lowranceusr4_find_global_waypt(uint id1, uint id2, uint id3, uint id4)
{
-#if !NEWQ
- queue* elem, *tmp;
-#endif
lowranceusr4_fsdata* fs = nullptr;
-#if NEWQ
// Iterate with waypt_disp_all?
- foreach (Waypoint* waypointp, waypt_list) {
-#else
- QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- Waypoint* waypointp = reinterpret_cast<Waypoint*>(elem);
-#endif
+ foreach (Waypoint* waypointp, *global_waypoint_list) {
fs = (lowranceusr4_fsdata*) fs_chain_find(waypointp->fs, FS_LOWRANCEUSR4);
if (fs && fs->UUID1 == id1 &&
#include "gbfile.h" // for gbfclose, gbfeof, gbfgets, gbfopen, gbfwrite, gbfile
#include "gbser.h" // for gbser_deinit, gbser_init, gbser_is_serial, gbser_read_line, gbser_set_port, gbser_write, gbser_OK
#include "magellan.h" // for mm_meridian, mm_sportrak, icon_mapping_t, mm_gps315320, mm_unknown, mm_map330, mm_map410, pid_to_model_t, mm_gps310, m330_cleanse, mag_checksum, mag_find_descr_from_token, mag_find_token_from_descr, mag_rteparse, mag_trkparse
-#include "queue.h" // for queue, QUEUE_FOR_EACH
#include "src/core/datetime.h" // for DateTime
/*
* This is the first component of a route. Allocate a new
- * queue head.
+ * head.
*/
if (frag == 1) {
mag_rte_head = new mag_rte_head_t;
static void
mag_route_trl(const route_head* rte)
{
- queue* elem, *tmp;
char obuff[256];
char buff1[64], buff2[64];
char* pbuff;
route_out_count++;
int thisline = i = 0;
- QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) {
- Waypoint* waypointp = reinterpret_cast<Waypoint *>(elem);
+ foreach (const Waypoint* waypointp, rte->waypoint_list) {
i++;
if (deficon) {
// Write name, icon tuple into alternating buff1/buff2 buffer.
sprintf(pbuff, "%s,%s", CSTR(waypointp->shortname), CSTR(icon_token));
- if ((tmp == &rte->waypoint_list) || ((i % 2) == 0)) {
+ if ((waypointp == rte->waypoint_list.back()) || ((i % 2) == 0)) {
char expbuf[1024];
thisline++;
expbuf[0] = 0;
#include "filter.h" // for Filter
#include "filterdefs.h" // for disp_filter_vec, disp_filter_vecs, disp_filters, exit_filter_vecs, find_filter_vec, free_filter_vec, init_filter_vecs
#include "inifile.h" // for inifile_done, inifile_init
-#include "queue.h" // for queue
#include "session.h" // for start_session, session_exit, session_init
#include "src/core/datetime.h" // for DateTime
#include "src/core/file.h" // for File
const char* fvec_opts = nullptr;
int opt_version = 0;
bool did_something = false;
- queue* wpt_head_bak;
- RouteList* rte_head_bak, *trk_head_bak;
- signed int wpt_ct_bak;
+ WaypointList* wpt_head_bak;
+ RouteList* rte_head_bak;
+ RouteList* trk_head_bak;
bool lists_backedup;
QStack<QargStackElement> qargs_stack;
cet_convert_init(ovecs->encode, ovecs->fixed_encode);
lists_backedup = false;
- rte_head_bak = trk_head_bak = nullptr;
+ wpt_head_bak = nullptr;
+ rte_head_bak = nullptr;
+ trk_head_bak = nullptr;
ovecs->wr_init(ofname);
int saved_status = global_opts.verbose_status;
global_opts.verbose_status = 0;
lists_backedup = true;
- waypt_backup(&wpt_ct_bak, &wpt_head_bak);
+ waypt_backup(&wpt_head_bak);
route_backup(&rte_head_bak);
track_backup(&trk_head_bak);
cet_convert_deinit();
if (lists_backedup) {
- waypt_restore(wpt_ct_bak, wpt_head_bak);
+ waypt_restore(wpt_head_bak);
+ delete wpt_head_bak;
route_restore(rte_head_bak);
delete rte_head_bak;
track_restore(trk_head_bak);
*/
+#include <cmath> // for fabs
+#include <cstring> // for memset
+
+#include <QtCore/QDate> // for QDate
+#include <QtCore/QDateTime> // for QDateTime
+#include <QtCore/QString> // for QString
+#include <QtCore/QTime> // for QTime
+#include <QtCore/Qt> // for UTC
+#include <QtCore/QtGlobal> // for foreach
+
#include "defs.h"
-#include <cctype>
-#include <cmath>
-#include <cstring>
-#include <ctime>
-//#include "session.h"
+#include "gbfile.h" // for gbfclose, gbfeof, gbfgetint32, gbfputint32, gbfread, gbfwrite, gbfile, gbfopen_le
+#include "session.h" // for curr_session
+#include "src/core/datetime.h" // for DateTime
+
#define MYNAME "mapasia"
static void
tr7_check_after_read_trailer_cb(const route_head* trk)
{
- queue* elem, *tmp;
- QUEUE_FOR_EACH((queue*)&trk->waypoint_list, elem, tmp) {
- Waypoint* wpt = reinterpret_cast<Waypoint *>(elem);
+ foreach (Waypoint* wpt, trk->waypoint_list) {
if (speed_tmp == 0) {
WAYPT_UNSET(wpt, speed);
}
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
*/
+#include <cmath> // for lround
+#include <cstdio> // for sprintf
+#include <cstdlib> // for atoi
+#include <cstring> // for strncpy
+#include <ctime>
+
+#include <QtCore/QCharRef> // for QCharRef
+#include <QtCore/QString> // for QString
+#include <QtCore/QTime> // for QTime
+#include <QtCore/QtGlobal> // for Q_UNUSED
+
#include "defs.h"
-#include "magellan.h"
#include "mapsend.h"
-#include <cmath>
-#include <cstdio>
-#include <cstdlib>
+#include "gbfile.h" // for gbfputint32, gbfgetint32, gbfgetdbl, gbfputdbl, gbfgetpstr, gbfwrite, gbfputpstr, gbfputc, gbfread, gbfclose, gbfgetc, gbfgetflt, gbfopen, gbfputflt, gbfile, gbfgetuint32, gbfopen_le, gbsize_t
+#include "magellan.h" // for mag_find_token_from_descr, mag_find_descr_from_token
+#include "src/core/datetime.h" // for DateTime
+
static gbfile* mapsend_file_in;
static gbfile* mapsend_file_out;
* tremendously out of whack time/date wise.
*/
const char* verstring = "30";
- queue* elem, *tmp;
mapsend_hdr hdr = {13, {'4','D','5','3','3','3','3','4',' ','M','S'},
{'3','0'}, ms_type_track, {0, 0, 0}
};
gbfputpstr(tname, mapsend_file_out);
/* total nodes (waypoints) this track */
- int i = 0;
- QUEUE_FOR_EACH(&trk->waypoint_list, elem, tmp) {
- i++;
- }
+ int i = trk->waypoint_list.count();
gbfputint32(i, mapsend_file_out);
#include <cstdlib> // for atoi, rand, srand
#include <cstring> // for strcpy, memset, strlen, strcmp
#include <ctime> // for time_t
+#include <cstdio> // for SEEK_CUR
#include <QtCore/QChar> // for QChar
#include <QtCore/QFile> // for QFile
#include <QtCore/QList> // for QList
#include <QtCore/QString> // for QString, operator==
+#include <QtCore/QtGlobal> // for foreach
#include "defs.h"
#include "garmin_tables.h" // for gt_find_icon_number_from_desc, MAPSOURCE, gt_find_desc_from_icon_number, GARMIN_SERIAL, PCX, garmin_formats_e
#include "gbfile.h" // for gbfwrite, gbfread, gbfgetint32, gbfputint32, gbfseek, gbfputc, gbfgetc, gbfputdbl, gbfgetdbl, gbfclose, gbfeof, gbfile, gbftell, gbfgetcstr, gbfputs, gbfopen_le
#include "jeeps/gpsmath.h" // for GPS_Math_Deg_To_Semi, GPS_Math_Semi_To_Deg
-#include "queue.h" // for queue, QUEUE_FOR_EACH
#include "src/core/datetime.h" // for DateTime
double maxalt=unknown_alt;
double minalt=-unknown_alt;
- queue* elem, *tmp;
-
prevRouteWpt = nullptr; /* clear the stateful flag used to know when the start of route wpts happens */
memset(zbuf, 0, sizeof(zbuf));
unsigned int rte_datapoints = 0;
int allWptNameLengths = 0;
- if (rte->waypoint_list.next) { /* this test doesn't do what I want i.e test if this is a valid route - treat as a placeholder for now */
- QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) {
- Waypoint* testwpt = reinterpret_cast<Waypoint *>(elem);
+ //if (rte->waypoint_list.next) { /* this test doesn't do what I want i.e test if this is a valid route - treat as a placeholder for now */
+ if (true) {
+ foreach (const Waypoint* testwpt, rte->waypoint_list) {
if (rte_datapoints == 0) {
uniqueValue = testwpt->GetCreationTime().toTime_t();
}
(void)mps_ver;
hdr[0] = 1;
- if (rte->waypoint_list.next) { /* this test doesn't do what I want i.e test if this is a valid route - treat as a placeholder for now */
+ //if (rte->waypoint_list.next) { /* this test doesn't do what I want i.e test if this is a valid route - treat as a placeholder for now */
+ if (true) {
gbfwrite(&value, 4, 1, mps_file);
gbfwrite(hdr, 1, 1, mps_file);
}
char hdr[20];
time_t uniqueValue = 0;
- queue* elem, *tmp;
-
(void)mps_ver;
/* total nodes (waypoints) this track */
unsigned int trk_datapoints = 0;
- if (trk->waypoint_list.next) { /* this test doesn't do what I want i.e test if this is a valid track - treat as a placeholder for now */
- QUEUE_FOR_EACH(&trk->waypoint_list, elem, tmp) {
+ //if (trk->waypoint_list.next) { /* this test doesn't do what I want i.e test if this is a valid track - treat as a placeholder for now */
+ if (true) {
+ foreach (const Waypoint* testwpt, trk->waypoint_list) {
if (trk_datapoints == 0) {
- Waypoint* testwpt = reinterpret_cast<Waypoint *>(elem);
uniqueValue = testwpt->GetCreationTime().toTime_t();
}
trk_datapoints++;
*/
+#include <cctype> // for isspace
+#include <cerrno> // for errno
+#include <cstdio> // for SEEK_CUR, fprintf, size_t, stdout
+#include <cstdlib> // for abort, strtol
+#include <cstdint>
+#include <cstring> // for strcmp, strlen, memset, strchr, strncmp
+#include <ctime>
+
+#include <QtCore/QByteArray> // for QByteArray
+#include <QtCore/QChar> // for operator==, QChar
+#include <QtCore/QCharRef> // for QCharRef
+#include <QtCore/QDateTime> // for QDateTime
+#include <QtCore/QHash> // for QHash, QHash<>::const_iterator
+#include <QtCore/QLatin1String> // for QLatin1String
+#include <QtCore/QString> // for QString, operator==
+#include <QtCore/Qt> // for CaseInsensitive
+#include <QtCore/QtGlobal> // for qAsConst, QAddConst<>::Type, foreach, Q_UNUSED
+
#include "defs.h"
-#include <QtCore/QHash>
-#include <QtCore/QtGlobal>
-#include <cerrno>
-#include <cstdio>
-#include <cstdlib>
+#include "cet.h" // for cet_ucs4_to_utf8, cet_utf8_to_ucs4
+#include "gbfile.h" // for gbfputc, gbfgetuint16, gbfgetc, gbfgetdbl, gbfgetuint32, gbfputflt, gbfputuint32, gbfgetint16, gbfputdbl, gbfputuint16, gbfclose, gbfread, gbfseek, gbfputint16, gbfwrite, gbfcopyfrom, gbfeof, gbfgetflt, gbfgetint32, gbfile, gbfopen, gbfrewind, gbsize_t
+#include "session.h" // for curr_session, session_t
+#include "src/core/datetime.h" // for DateTime
+
#define MYNAME "mmo"
static void
mmo_write_rte_head_cb(const route_head* rte)
{
- queue* elem, *tmp;
time_t time = 0x7FFFFFFF;
if (rte->rte_waypt_ct <= 0) {
mmo_rte = rte;
- QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) {
- Waypoint* wpt = reinterpret_cast<Waypoint*>(elem);
+ foreach (const Waypoint* wpt, rte->waypoint_list) {
QDateTime t = wpt->GetCreationTime();
if ((t.isValid()) && (t.toTime_t() < time)) {
time = t.toTime_t();
static void
mmo_write_rte_tail_cb(const route_head* rte)
{
- queue* elem, *tmp;
-
if (rte->rte_waypt_ct <= 0) {
return;
}
}
}
- QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) {
- Waypoint* wpt = reinterpret_cast<Waypoint*>(elem);
+ foreach (const Waypoint* wpt, rte->waypoint_list) {
int objid = mmo_get_objid(wpt);
gbfputuint16(objid & 0x7FFF, fout);
}
*/
+#include <cctype> // for isspace
+#include <cstdio> // for snprintf
+#include <cstdlib> // for atoi, atof, qsort, strtol
+#include <cstring> // for strcpy, strlen, memset, strncmp, strstr
+#include <ctime> // for mktime
+
+#include <QtCore/QString> // for QString
+#include <QtCore/QtGlobal> // for foreach
+
#include "defs.h"
-#include "cet_util.h"
-#include "csv_util.h"
-#include <cctype>
-#include <cstdio>
-#include <cstdlib>
+#include "cet_util.h" // for cet_convert_init
+#include "csv_util.h" // for csv_lineparse
+#include "gbfile.h" // for gbfclose, gbfgetstr, gbfopen, gbfile
+
static gbfile* file_in;
static char* nseicon = nullptr;
htable_t* bh = htable;
int i = 0;
-#if NEWQ
// Why, oh, why is this format running over the entire waypoint list and
// modifying it? This seems wrong.
- extern QList<Waypoint*> waypt_list;
- foreach(Waypoint* waypointp, waypt_list) {
+ extern WaypointList* global_waypoint_list;
+ foreach(Waypoint* waypointp, *global_waypoint_list) {
bh->wpt = waypointp;
-#else
- queue* elem, *tmp;
- extern queue waypt_head;
- QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- bh->wpt = reinterpret_cast<Waypoint *>(elem);
-#endif
QString snptr = bh->wpt->shortname;
QString tmp_sn = snptr.toLower();
bh->crc = get_crc32(CSTR(tmp_sn), tmp_sn.length());
#include <cstdlib> // for atoi, atof
#include <cstring> // for strncmp, memset, strlen, strchr, strstr, strrchr
#include <ctime> // for gmtime
+#include <iterator> // for operator!=, reverse_iterator
#include <QtCore/QByteArray> // for QByteArray
#include <QtCore/QChar> // for QChar, operator==, operator!=
#include "gbfile.h" // for gbfprintf, gbfflush, gbfclose, gbfopen, gbfgetstr, gbfile
#include "gbser.h" // for gbser_set_speed, gbser_flush, gbser_read_line, gbser_deinit, gbser_init, gbser_write
#include "jeeps/gpsmath.h" // for GPS_Lookup_Datum_Index, GPS_Math_Known_Datum_To_WGS84_M
-#include "queue.h" // for queue, QUEUE_FOR_EACH, QUEUE_LAST
#include "src/core/datetime.h" // for DateTime
#include "src/core/logging.h" // for Warning
#include "strptime.h" // for strptime
}
if (tm.tm_year == 0) {
- queue* elem, *temp;
Waypoint* prev = nullptr;
if (optdate == nullptr) {
}
time_t delta_tm = mkgmtime(&opt_tm);
- QUEUE_FOR_EACH(&track->waypoint_list, elem, temp) {
- Waypoint* wpt = reinterpret_cast<Waypoint *>(elem);
+ foreach (Waypoint* wpt, track->waypoint_list) {
wpt->creation_time += delta_tm;
if ((prev != nullptr) && (prev->creation_time > wpt->creation_time)) {
/* go backward through the track and complete timestamps */
- for (queue* elem = QUEUE_LAST(&track->waypoint_list); elem != &track->waypoint_list; elem=elem->prev) {
- Waypoint* wpt = reinterpret_cast<Waypoint *>(elem);
+ for (auto it = track->waypoint_list.crbegin(); it != track->waypoint_list.crend(); ++it) {
+ Waypoint* wpt = *it;
if (wpt->wpt_flags.fmt_use != 0) {
wpt->wpt_flags.fmt_use = 0; /* reset flag */
*/
+#include <QtCore/QString> // for QString
+#include <QtCore/QStringRef> // for QStringRef
+#include <QtCore/QXmlStreamAttributes> // for QXmlStreamAttributes
#include "defs.h"
-#include "xmlgeneric.h"
-#include <QtCore/QXmlStreamAttributes>
+#include "xmlgeneric.h" // for cb_cdata, xg_callback, xg_string, cb_start, cb_end, xg_cb_type, xml_deinit, xml_init, xml_read, xg_tag_mapping
+
static int isFirst = 1;
static route_head* route = nullptr;
rd_deinit()
{
if (route != nullptr) {
- Waypoint* head = reinterpret_cast<Waypoint *>QUEUE_FIRST(&route->waypoint_list);
- Waypoint* tail = reinterpret_cast<Waypoint *>QUEUE_LAST(&route->waypoint_list);
+ Waypoint* head = route->waypoint_list.front();
+ Waypoint* tail = route->waypoint_list.back();
if (head != nullptr) {
route->rte_name = head->shortname;
}
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
*/
+
+#include <cstdio> // for sscanf
+#include <cstring> // for strchr, strlen, strspn
+
+#include <QtCore/QtGlobal> // for foreach
+
#include "defs.h"
-#include "filterdefs.h"
+#include "filterdefs.h" // for global_waypoint_list
#include "polygon.h"
-#include <cstdio>
+#include "gbfile.h" // for gbfclose, gbfgetstr, gbfopen, gbfile
+
#if FILTERS_ENABLED
#define MYNAME "Polygon filter"
void PolygonFilter::process()
{
- queue* elem, * tmp;
- Waypoint* waypointp;
extra_data* ed;
int fileline = 0;
int first = 1;
fileline);
} else if (lat1 != BADVAL && lon1 != BADVAL &&
lat2 != BADVAL && lon2 != BADVAL) {
-#if NEWQ
- foreach (Waypoint* waypointp, waypt_list) {
-#else
- QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- waypointp = reinterpret_cast<Waypoint *>(elem);
-#endif
+ foreach (Waypoint* waypointp, *global_waypoint_list) {
if (waypointp->extra_data) {
ed = (extra_data*) waypointp->extra_data;
} else {
}
gbfclose(file_in);
-#if NEWQ
- foreach (Waypoint* wp, waypt_list) {
-#else
- QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- Waypoint* wp = reinterpret_cast<Waypoint *>(elem);
-#endif
+ foreach (Waypoint* wp, *global_waypoint_list) {
ed = (extra_data*) wp->extra_data;
wp->extra_data = nullptr;
if (ed) {
*/
+#include <cmath> // for fabs
+#include <cstdlib> // for strtod
+
+#include <QtCore/QtGlobal> // for foreach
+
#include "defs.h"
#include "filterdefs.h"
-#include "grtcirc.h"
+#include "grtcirc.h" // for RAD, gcdist, radtomiles
#include "position.h"
-#include <cmath>
-#include <cstdlib>
#if FILTERS_ENABLED
}
/* tear through a waypoint queue, processing points by distance */
-void PositionFilter::position_runqueue(queue* q, int nelems, int qtype)
+void PositionFilter::position_runqueue(WaypointList* waypt_list, int nelems, int qtype)
{
- queue* elem, * tmp;
double dist, diff_time;
int i = 0, anyitem;
Waypoint** comp = (Waypoint**) xcalloc(nelems, sizeof(*comp));
int* qlist = (int*) xcalloc(nelems, sizeof(*qlist));
-#if NEWQ
- foreach (Waypoint* waypointp, waypt_list) {
+ foreach (Waypoint* waypointp, *waypt_list) {
comp[i] = waypointp;
-#else
- QUEUE_FOR_EACH(q, elem, tmp) {
- comp[i] = reinterpret_cast<Waypoint *>(elem);
-#endif
qlist[i] = 0;
i++;
}
if (i) {
cur_rte = const_cast<route_head*>(rh);
- position_runqueue(const_cast<queue*>(&rh->waypoint_list), i, type);
+ position_runqueue(&cur_rte->waypoint_list, i, type);
cur_rte = nullptr;
}
int i = waypt_count();
if (i) {
- position_runqueue(&waypt_head, i, wptdata);
+ position_runqueue(global_waypoint_list, i, wptdata);
}
route_disp_all(position_process_rte_f, nullptr, nullptr);
#include "defs.h" // for route_head (ptr only), ARG_NOMINMAX, ARGTYPE_FLOAT
#include "filter.h" // for Filter
-#include "queue.h" // for queue
#if FILTERS_ENABLED
};
double gc_distance(double lat1, double lon1, double lat2, double lon2);
- void position_runqueue(queue* q, int nelems, int qtype);
+ void position_runqueue(WaypointList* waypt_list, int nelems, int qtype);
void position_process_any_route(const route_head* rh, int type);
void position_process_rte(const route_head* rh);
void position_process_trk(const route_head* rh);
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
*/
+#include <cctype> // for isspace
+#include <cstdio> // for sscanf, EOF, size_t
+#include <cstdlib> // for atof, atoi
+#include <cstring> // for strcmp, strlen, strcpy
+#include <ctime> // for gmtime
+
+#include <QtCore/QChar> // for QChar
+#include <QtCore/QLatin1String> // for QLatin1String
+#include <QtCore/QString> // for QString
+#include <QtCore/QtGlobal> // for foreach, uint
+
#include "defs.h"
-#include "garmin_tables.h"
-#include <cctype>
-#include <cstdio>
-#include <cstdlib>
+#include "garmin_tables.h" // for gt_find_desc_from_icon_number, gt_find_icon_number_from_desc, PCX
+#include "gbfile.h" // for gbfprintf, gbfeof, gbfile, gbfgetc, gbfclose, gbfgets, gbfopen, gbfputs
+#include "src/core/datetime.h" // for DateTime
+
#define MYNAME "PSITREX"
QString rname;
/* total nodes (waypoints) this route */
- if (rte->waypoint_list.next) {
+ //if (rte->waypoint_list.next) {
+ if (true) {
// this test doesn't do what I w ant i.e test if this is a valid
// route - treat as a placeholder for now .
time_t uniqueValue = 0;
unsigned int rte_datapoints = 0;
- queue *elem, *tmp;
- QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) {
- Waypoint* testwpt = reinterpret_cast<Waypoint*>(elem);
+ foreach (const Waypoint* testwpt, rte->waypoint_list) {
if (rte_datapoints == 0) {
uniqueValue = testwpt->GetCreationTime().toTime_t();
}
QString tname;
time_t uniqueValue = 0;
- queue* elem, *tmp;
-
if (psit_track_state == 2) {
/* total nodes (waypoints) this track */
- if (trk->waypoint_list.next) { /* this test doesn't do what I want i.e test if this is a valid track - treat as a placeholder for now */
+ //if (trk->waypoint_list.next) { /* this test doesn't do what I want i.e test if this is a valid track - treat as a placeholder for now */
+ if (true) {
unsigned int trk_datapoints = 0;
- QUEUE_FOR_EACH(&trk->waypoint_list, elem, tmp) {
+ foreach (const Waypoint* testwpt, trk->waypoint_list) {
if (trk_datapoints == 0) {
- Waypoint* testwpt = reinterpret_cast<Waypoint*>(elem);
uniqueValue = testwpt->GetCreationTime().toTime_t();
}
trk_datapoints++;
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
*/
+
+#include <cstdlib> // for atof, atoi, qsort, strtod
+
+#include <QtCore/QString> // for QString
+#include <QtCore/QtGlobal> // for foreach
+
#include "defs.h"
#include "filterdefs.h"
-#include "grtcirc.h"
#include "radius.h"
-#include <cstdio>
-#include <cstdlib>
+#include "grtcirc.h" // for RAD, gcdist, radtomiles
#if FILTERS_ENABLED
void RadiusFilter::process()
{
-#if !NEWQ
- queue* elem, * tmp;
-#endif
Waypoint** comp;
int i, wc;
route_head* rte_head = nullptr;
-#if NEWQ
- foreach (Waypoint* waypointp, waypt_list) {
-#else
- QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- Waypoint* waypointp = reinterpret_cast<Waypoint *>(elem);
-#endif
+ foreach (Waypoint* waypointp, *global_waypoint_list) {
double dist = gc_distance(waypointp->latitude,
waypointp->longitude,
home_pos->latitude,
* for qsort.
*/
-#if NEWQ
- foreach (Waypoint* wp, waypt_list) {
-#else
- QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- Waypoint* wp = reinterpret_cast<Waypoint *>(elem);
-#endif
+ foreach (Waypoint* wp, *global_waypoint_list) {
comp[i] = wp;
waypt_del(wp);
i++;
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
*/
+#include <algorithm> // for reverse
+
+#include <QtCore/QList> // for QList<>::iterator
+
#include "defs.h"
#include "filterdefs.h"
#include "reverse_route.h"
{
/* Cast away const-ness */
auto rh = const_cast<route_head*>(rte_hd);
- queue* elem, *tmp;
- QUEUE_FOR_EACH(&rh->waypoint_list, elem, tmp) {
- ENQUEUE_HEAD(&rh->waypoint_list, dequeue(elem));
- }
+ std::reverse(rh->waypoint_list.begin(), rh->waypoint_list.end());
prev_new_trkseg = 1;
}
*/
+#include <cassert> // for assert
+#include <cstddef> // for nullptr_t
+#include <algorithm> // for sort
+#include <iterator>
+
+#include <QtCore/QDateTime> // for QDateTime
+#include <QtCore/QList> // for QList<>::iterator
+#include <QtCore/QString> // for QString
+#include <QtCore/QtGlobal> // for foreach
+
#include "defs.h"
#include "grtcirc.h" // for RAD, gcdist, heading_true_degrees, radtometers
-#include "queue.h" // for dequeue, queue, QUEUE_FOR_EACH, QUEUE_EMPTY, ENQUEUE_HEAD, ENQUEUE_TAIL, QUEUE_INIT, QUEUE_LAST, QUEUE_NEXT
#include "session.h" // for curr_session, session_t (ptr only)
#include "src/core/datetime.h" // for DateTime
#include "src/core/optional.h" // for optional, operator>, operator<
-#include <QtCore/QDateTime> // for QDateTime
-#include <QtCore/QList> // for QList<>::iterator
-#include <QtCore/QString> // for QString
-#include <QtCore/QtGlobal> // for foreach
-#include <algorithm> // for sort
-#include <cstddef> // for nullptr_t
+
RouteList* global_route_list;
RouteList* global_track_list;
// First point in a route is always a new segment.
// This improves compatibility when reading from
// segment-unaware formats.
- if (QUEUE_EMPTY(&rte->waypoint_list)) {
+ if (rte->waypoint_list.empty()) {
wpt->wpt_flags.new_trkseg = 1;
}
// First point in a track is always a new segment.
// This improves compatibility when reading from
// segment-unaware formats.
- if (QUEUE_EMPTY(&rte->waypoint_list)) {
+ if (rte->waypoint_list.empty()) {
wpt->wpt_flags.new_trkseg = 1;
}
computed_trkdata track_recompute(const route_head* trk)
{
Waypoint first;
- Waypoint* prev = &first;
- queue* elem, *tmp;
+ const Waypoint* prev = &first;
int tkpt = 0;
int pts_hrt = 0;
double tot_hrt = 0.0;
// first.longitude = 0;
// first.creation_time = 0;
- QUEUE_FOR_EACH(&trk->waypoint_list, elem, tmp) {
- auto thisw = reinterpret_cast<Waypoint*>(elem);
+ foreach (Waypoint* thisw, trk->waypoint_list) {
/*
* gcdist and heading want radians, not degrees.
line_width(-1),
session(curr_session())
{
- QUEUE_INIT(&waypoint_list);
};
route_head::~route_head()
{
- waypt_flush(&waypoint_list);
+ waypoint_list.flush();
if (fs) {
fs_chain_destroy(fs);
}
{
waypt_ct -= rte->rte_waypt_ct;
const int idx = this->indexOf(rte);
+ assert(idx >= 0);
removeAt(idx);
delete rte;
}
RouteList::insert_head(route_head* rte, route_head* predecessor)
{
const int idx = this->indexOf(predecessor);
+ assert(idx >= 0);
this->insert(idx + 1, rte);
}
void
RouteList::add_wpt(route_head* rte, Waypoint* wpt, bool synth, const QString& namepart, int number_digits)
{
- ENQUEUE_TAIL(&rte->waypoint_list, &wpt->Q);
rte->rte_waypt_ct++; /* waypoints in this route */
++waypt_ct;
- if (synth && wpt->shortname.isEmpty()) {
- wpt->shortname = QString("%1%2").arg(namepart).arg(waypt_ct, number_digits, 10, QChar('0'));
- wpt->wpt_flags.shortname_is_synthetic = 1;
+ rte->waypoint_list.add_rte_waypt(waypt_ct, wpt, synth, namepart, number_digits);
+ if ((this == global_route_list) || (this == global_track_list)) {
+ update_common_traits(wpt);
}
- update_common_traits(wpt);
}
void
RouteList::del_wpt(route_head* rte, Waypoint* wpt)
{
- if (wpt->wpt_flags.new_trkseg && wpt != reinterpret_cast<Waypoint*>QUEUE_LAST(&rte->waypoint_list)) {
- auto wpt_next = reinterpret_cast<Waypoint*>QUEUE_NEXT(&wpt->Q);
- wpt_next->wpt_flags.new_trkseg = 1;
- }
- wpt->wpt_flags.new_trkseg = 0;
- dequeue(&wpt->Q);
+ rte->waypoint_list.del_rte_waypt(wpt);
rte->rte_waypt_ct--;
--waypt_ct;
}
void
RouteList::flush()
{
- foreach (route_head* rte, *this) {
- delete rte;
+ while (!isEmpty()) {
+ delete takeFirst();
}
- clear();
waypt_ct = 0;
}
void
RouteList::copy(RouteList** dst) const
{
- queue* elem2, *tmp2;
-
if (*dst == nullptr) {
*dst = new RouteList;
}
rte_new->fs = fs_chain_copy(rte_old->fs);
rte_new->rte_num = rte_old->rte_num;
(*dst)->add_head(rte_new);
- QUEUE_FOR_EACH(&rte_old->waypoint_list, elem2, tmp2) {
- (*dst)->add_wpt(rte_new, new Waypoint(*reinterpret_cast<Waypoint*>(elem2)), false, RPT, 3);
+ foreach (const Waypoint* old_wpt, rte_old->waypoint_list) {
+ (*dst)->add_wpt(rte_new, new Waypoint(*old_wpt), false, RPT, 3);
}
}
}
{
std::sort(begin(), end(), cmp);
}
-
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
*/
+
+#include <QtCore/QDateTime> // for QDateTime
+#include <QtCore/QString> // for operator<, QString
+
#include "defs.h"
+#include "src/core/datetime.h" // for DateTime
#include "filterdefs.h"
#include "sort.h"
-#include <QtCore/QString> // for QString
-#include <cstdlib> // for abort
#if FILTERS_ENABLED
#define MYNAME "sort"
-template <class T>
-inline int sgn(T v)
+
+bool SortFilter::sort_comp_wpt_by_description(const Waypoint* a, const Waypoint* b)
{
-// Returns 1 if v > 0, -1 if v < 0, and 0 if v is zero
- return (v > T(0)) - (v < T(0));
+ return a->description < b->description;
}
-template <class T>
-inline int cmp(T a, T b)
+bool SortFilter::sort_comp_wpt_by_gcid(const Waypoint* a, const Waypoint* b)
{
-// Returns 1 if a > b, -1 if a < b, and 0 if a = b
-// note possible overflow in computing sgn(a-b) is avoided.
- return (a > b) - (a < b);
+ return a->gc_data->id < b->gc_data->id;
}
-int SortFilter::sort_comp_wpt(const queue* a, const queue* b)
+bool SortFilter::sort_comp_wpt_by_shortname(const Waypoint* a, const Waypoint* b)
{
- const Waypoint* x1 = reinterpret_cast<const Waypoint*>(a);
- const Waypoint* x2 = reinterpret_cast<const Waypoint*>(b);
-
- switch (wpt_sort_mode) {
- case SortModeWpt::description:
- return x1->description.compare(x2->description);
- case SortModeWpt::gcid:
- return cmp(x1->gc_data->id, x2->gc_data->id);
- case SortModeWpt::shortname:
- return x1->shortname.compare(x2->shortname);
- case SortModeWpt::time:
- return sgn(x2->GetCreationTime().msecsTo(x1->GetCreationTime()));
- default:
- abort();
- return 0; /* Internal caller error. */
- }
+ return a->shortname < b->shortname;
+}
+
+bool SortFilter::sort_comp_wpt_by_time(const Waypoint* a, const Waypoint* b)
+{
+ return a->GetCreationTime() < b->GetCreationTime();
}
bool SortFilter::sort_comp_rh_by_description(const route_head* a, const route_head* b)
bool SortFilter::sort_comp_rh_by_number(const route_head* a, const route_head* b)
{
- return a->rte_num < b->rte_num;
-}
-
-int SortFilter::SortCompWptFunctor::operator()(const queue* a, const queue* b)
-{
- return that->sort_comp_wpt(a, b);
+ return a->rte_num < b->rte_num;
}
void SortFilter::process()
{
- SortCompWptFunctor sort_comp_wpt_f(*this);
-
if (wpt_sort_mode != SortModeWpt::none) {
- sortqueue(&waypt_head, sort_comp_wpt_f);
+ switch (wpt_sort_mode) {
+ case SortModeWpt::description:
+ waypt_sort(sort_comp_wpt_by_description);
+ break;
+ case SortModeWpt::gcid:
+ waypt_sort(sort_comp_wpt_by_gcid);
+ break;
+ case SortModeWpt::shortname:
+ waypt_sort(sort_comp_wpt_by_shortname);
+ break;
+ case SortModeWpt::time:
+ waypt_sort(sort_comp_wpt_by_time);
+ break;
+ default:
+ fatal(MYNAME ": unknown waypoint sort mode.");
+ }
}
+
if (rte_sort_mode != SortModeRteHd::none) {
switch (rte_sort_mode) {
case SortModeRteHd::description:
#include "defs.h" // for ARGTYPE_BOOL, ARG_NOMINMAX, arglist_t, ARG_TERMI...
#include "filter.h" // for Filter
-#include "queue.h" // for queue
#if FILTERS_ENABLED
ARG_TERMINATOR
};
- int sort_comp_wpt(const queue* a, const queue* b);
+ static bool sort_comp_wpt_by_description(const Waypoint* a, const Waypoint* b);
+ static bool sort_comp_wpt_by_gcid(const Waypoint* a, const Waypoint* b);
+ static bool sort_comp_wpt_by_shortname(const Waypoint* a, const Waypoint* b);
+ static bool sort_comp_wpt_by_time(const Waypoint* a, const Waypoint* b);
static bool sort_comp_rh_by_description(const route_head* a, const route_head* b);
static bool sort_comp_rh_by_name(const route_head* a, const route_head* b);
static bool sort_comp_rh_by_number(const route_head* a, const route_head* b);
- class SortCompWptFunctor
- {
- public:
- explicit SortCompWptFunctor(SortFilter& obj) : that(&obj) {}
- int operator()(const queue* a, const queue* b);
-
- private:
- SortFilter* that;
- };
-
};
#endif // FILTERS_ENABLED
#endif // SORT_H_INCLUDED_
*/
+#include <cstdlib> // for atoi
+
#include "defs.h"
#include "filterdefs.h"
#include "stackfilter.h"
-#include <cstdlib>
#if FILTERS_ENABLED
void StackFilter::process()
{
stack_elt* tmp_elt = nullptr;
- queue* elem = nullptr;
- queue* tmp = nullptr;
- queue tmp_queue;
+ WaypointList* waypt_list_ptr;
RouteList* route_list_ptr;
if (opt_push) {
tmp_elt = new stack_elt;
-
- QUEUE_MOVE(&(tmp_elt->waypts), &waypt_head);
- tmp_elt->waypt_ct = waypt_count();
- set_waypt_count(0);
tmp_elt->next = stack;
stack = tmp_elt;
- if (opt_copy) {
- QUEUE_FOR_EACH(&(stack->waypts), elem, tmp) {
- waypt_add(new Waypoint(*reinterpret_cast<Waypoint *>(elem)));
- }
+
+ waypt_list_ptr = &(tmp_elt->waypts);
+ waypt_backup(&waypt_list_ptr);
+ if (!opt_copy) {
+ waypt_flush_all();
}
route_list_ptr = &(tmp_elt->routes);
fatal(MYNAME ": stack empty\n");
}
if (opt_append) {
- QUEUE_FOR_EACH(&(stack->waypts), elem, tmp) {
- waypt_add(reinterpret_cast<Waypoint *>(elem));
- }
+ waypt_append(&(stack->waypts));
+ stack->waypts.flush();
route_append(&(stack->routes));
stack->routes.flush();
track_append(&(stack->tracks));
stack->tracks.flush();
} else if (opt_discard) {
- waypt_flush(&(stack->waypts));
+ stack->waypts.flush();
stack->routes.flush();
stack->tracks.flush();
} else {
- waypt_flush(&waypt_head);
- QUEUE_MOVE(&(waypt_head), &(stack->waypts));
- set_waypt_count(stack->waypt_ct);
-
+ waypt_restore(&(stack->waypts));
route_restore(&(stack->routes));
track_restore(&(stack->tracks));
}
tmp_elt = tmp_elt->next;
swapdepth--;
}
- QUEUE_MOVE(&tmp_queue, &(tmp_elt->waypts));
- QUEUE_MOVE(&(tmp_elt->waypts), &waypt_head);
- QUEUE_MOVE(&waypt_head, &tmp_queue);
- unsigned int tmp_count = waypt_count();
- set_waypt_count(tmp_elt->waypt_ct);
- tmp_elt->waypt_ct = tmp_count;
+
+ waypt_swap(tmp_elt->waypts);
route_swap(tmp_elt->routes);
"check command line for mistakes\n");
}
while (stack) {
- waypt_flush(&(stack->waypts));
+ stack->waypts.flush();
stack->routes.flush();
stack->tracks.flush();
tmp_elt = stack;
#include "defs.h" // for ARGTYPE_BOOL, ARG_NOMINMAX, ARGTYPE_BEGIN_EXCL
#include "filter.h" // for Filter
-#include "queue.h" // for queue
#if FILTERS_ENABLED
ARG_TERMINATOR
};
- class stack_elt
+ struct stack_elt
{
- public:
- stack_elt()
- {
- QUEUE_INIT(&waypts);
- }
-
- queue waypts;
+ WaypointList waypts;
RouteList routes;
RouteList tracks;
- unsigned int waypt_ct{0};
stack_elt* next{nullptr};
};
stack_elt* stack = nullptr;
description string beyond the NUL terminator. -- Ron Parker, 17 July 2006
*/
+#include <cstdio> // for printf, snprintf, SEEK_CUR, EOF
+#include <cstdlib> // for qsort
+#include <cstring> // for strlen
+
+#include <QtCore/QString> // for QString
+#include <QtCore/QtGlobal> // for foreach
#include "defs.h"
-#include <QtCore/QTextCodec>
-#include <cstdio> // sprintf
-#include <cstdlib> // qsort
+#include "gbfile.h" // for gbfgetint32, gbfputint32, gbfclose, gbfgetc, gbfputc, gbfseek, gbfile, gbfeof, gbfread, gbftell, gbfwrite, gbfopen_le
+
#define MYNAME "TomTom"
{
int ct = waypt_count();
struct hdr* htable, *bh;
-#if NEWQ
- extern QList<Waypoint*> waypt_list;
-#else
- queue* elem, *tmp;
- extern queue waypt_head;
-#endif
+ extern WaypointList* global_waypoint_list;
double minlon = 200;
double maxlon = -200;
double minlat = 200;
htable = (struct hdr*) xmalloc(ct * sizeof(*htable));
bh = htable;
-#if NEWQ
// Iterate with waypt_disp_all?
- foreach(Waypoint* waypointp, waypt_list) {
-#else
- QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- Waypoint* waypointp = reinterpret_cast<Waypoint *>(elem);
-#endif
+ foreach(Waypoint* waypointp, *global_waypoint_list) {
bh->wpt = waypointp;
if (waypointp->longitude > maxlon) {
maxlon = waypointp->longitude;
3.x "recreation"
*/
+#include <cassert> // for assert
+#include <cmath> // for cos, sqrt
+#include <cstdio> // for printf, sprintf, SEEK_CUR, SEEK_SET
+#include <cstdint>
+#include <cstring> // for strncmp, strlen, memset
+#include <vector> // for vector
+
+#include <QtCore/QByteArray> // for QByteArray
+#include <QtCore/QChar> // for operator==, QChar
+#include <QtCore/QCharRef> // for QCharRef
+#include <QtCore/QScopedArrayPointer> // for QScopedArrayPointer
+#include <QtCore/QString> // for QString
+#include <QtCore/QtGlobal> // for qPrintable, Q_UNUSED
#include "defs.h"
-#include "jeeps/gpsmath.h" /* for datum conversions */
-#include <QtCore/QScopedArrayPointer> // Wish we could use c++11...
-#include <cassert>
-#include <cmath>
-#include <cstdio>
-#include <cstdlib>
-#include <vector>
+#include "gbfile.h" // for gbfread, gbfgetc, gbfgetint32, gbfwrite, gbfputint16, gbfseek, gbfgetdbl, gbfgetint16, gbfputdbl, gbfclose, gbfputint32, gbfile, gbfopen_le, gbfgetuint16
+#include "jeeps/gpsmath.h" // for GPS_Math_WGS84LatLonH_To_XYZ, GPS_Math_WGS84_To_Known_Datum_M, GPS_Math_Deg_To_Rad, GPS_Math_Known_Datum_To_WGS84_M
+
#define MYNAME "TPO"
unsigned char unknown1[] = { 0xFF, 0x00, 0x00, 0x00 };
unsigned char bounding_box[8] = { 0x00, 0x80, 0x00, 0x80, 0xFF, 0x7F, 0xFF, 0x7F };
- Waypoint* first_track_waypoint = reinterpret_cast<Waypoint *>QUEUE_FIRST(&rte->waypoint_list);
+ Waypoint* first_track_waypoint = rte->waypoint_list.front();
/* zoom level 1-5 visibility flags */
gbfwrite(visibility_flags, 1, sizeof(visibility_flags), tpo_file_out);
#undef TRACKF_DBG
-#include "defs.h"
-#include "filterdefs.h"
-#include "queue.h" // for queue, QUEUE_FOR_EACH, QUEUE_FIRST, QUEUE_LAST, QUEUE_NEXT
-#include "grtcirc.h" // for RAD, gcdist, heading_true_degrees, radtometers, radtomiles
-#include "strptime.h"
-#include "trackfilter.h"
-#include "src/core/datetime.h" // for DateTime
+#include <cassert> // for assert
+#include <cmath> // for nan
+#include <cstdio> // for printf
+#include <cstdlib> // for abs
+#include <cstring> // for strlen, strchr, strcmp
+#include <ctime> // for gmtime, strftime
+#include <iterator> // for next
+
+#include <algorithm> // for sort, stable_sort
+
#include <QtCore/QByteArray> // for QByteArray
#include <QtCore/QChar> // for QChar
#include <QtCore/QDate> // for QDate
#ifdef TRACKF_DBG
#include <QtCore/QDebug>
#endif
-#include <QtCore/QList> // for QList<>::iterator, QList
-#include <QtCore/QtGlobal> // for qint64, qPrintable
+#include <QtCore/QList> // for QList<>::iterator, QList, QList<>::const_iterator
#include <QtCore/QRegExp> // for QRegExp, QRegExp::WildcardUnix
#include <QtCore/QRegularExpression> // for QRegularExpression, QRegularExpression::CaseInsensitiveOption, QRegularExpression::PatternOptions
#include <QtCore/QRegularExpressionMatch> // for QRegularExpressionMatch
#include <QtCore/QString> // for QString
#include <QtCore/Qt> // for UTC, CaseInsensitive
-#include <algorithm> // for sort, stable_sort
-#include <cassert> // for assert
-#include <cmath> // for nan
-#include <cstdio> // for printf
-#include <cstdlib> // for abs
-#include <cstring> // for strlen, strchr, strcmp
-#include <ctime> // for gmtime, strftime
+#include <QtCore/QtGlobal> // for qAsConst, foreach, qPrintable, QAddConst<>::Type, qint64
+
+#include "defs.h"
+#include "filterdefs.h"
+#include "trackfilter.h"
+
+#include "grtcirc.h" // for RAD, gcdist, radtometers, heading_true_degrees
+#include "src/core/datetime.h" // for DateTime
+
#if FILTERS_ENABLED || MINIMAL_FILTERS
#define MYNAME "trackfilter"
QDateTime TrackFilter::trackfilter_get_first_time(const route_head* track)
{
- if (QUEUE_EMPTY(&track->waypoint_list)) {
+ if (track->waypoint_list.empty()) {
return QDateTime();
} else {
- return reinterpret_cast<Waypoint*>(QUEUE_FIRST(&track->waypoint_list))->GetCreationTime();
+ return track->waypoint_list.front()->GetCreationTime();
}
}
QDateTime TrackFilter::trackfilter_get_last_time(const route_head* track)
{
- if (QUEUE_EMPTY(&track->waypoint_list)) {
+ if (track->waypoint_list.empty()) {
return QDateTime();
} else {
- return reinterpret_cast<Waypoint*>(QUEUE_LAST(&track->waypoint_list))->GetCreationTime();
+ return track->waypoint_list.back()->GetCreationTime();
}
}
void TrackFilter::trackfilter_fill_track_list_cb(const route_head* track) /* callback for track_disp_all */
{
- queue* elem, *tmp;
-
if (track->rte_waypt_ct == 0) {
track_del_head(const_cast<route_head*>(track));
return;
if (opt_name != nullptr) {
if (!QRegExp(opt_name, Qt::CaseInsensitive, QRegExp::WildcardUnix).exactMatch(track->rte_name)) {
- QUEUE_FOR_EACH(&track->waypoint_list, elem, tmp) {
- auto wpt = reinterpret_cast<Waypoint*>(elem);
+ foreach (Waypoint* wpt, track->waypoint_list) {
track_del_wpt(const_cast<route_head*>(track), wpt);
delete wpt;
}
}
}
- Waypoint* prev = nullptr;
+ const Waypoint* prev = nullptr;
- QUEUE_FOR_EACH(&track->waypoint_list, elem, tmp) {
- auto wpt = reinterpret_cast<Waypoint*>(elem);
+ foreach (const Waypoint* wpt, track->waypoint_list) {
if (!(opt_merge && opt_discard) && need_time && (!wpt->creation_time.isValid())) {
fatal(MYNAME "-init: Found track point at %f,%f without time!\n",
wpt->latitude, wpt->longitude);
if (track->rte_waypt_ct == 0) {
dt = default_time;
} else {
- auto wpt = reinterpret_cast<Waypoint*>QUEUE_FIRST(&track->waypoint_list);
+ auto wpt = track->waypoint_list.front();
dt = wpt->GetCreationTime();
}
time_t t = dt.toTime_t();
while (track_list.size() > 1) {
route_head* curr = track_list.takeAt(1);
- queue* elem, *tmp;
- QUEUE_FOR_EACH(&curr->waypoint_list, elem, tmp) {
- auto wpt = reinterpret_cast<Waypoint*>(elem);
+ foreach (Waypoint* wpt, curr->waypoint_list) {
track_del_wpt(curr, wpt);
track_add_wpt(master, wpt);
}
auto it = track_list.begin();
while (it != track_list.end()) { /* put all points into temp buffer */
route_head* track = *it;
- queue* elem, *tmp;
- QUEUE_FOR_EACH(&track->waypoint_list, elem, tmp) {
- auto wpt = reinterpret_cast<Waypoint*>(elem);
+ foreach (Waypoint* wpt, track->waypoint_list) {
track_del_wpt(track, wpt); /* copies any new_trkseg flag forward, and clears new_trkseg flag. */
if (wpt->creation_time.isValid()) {
// we will put the merged points in one track segment,
route_head* master = track_list.first();
int count = master->rte_waypt_ct;
- queue* elem, *tmp;
int i, j;
double interval = -1; /* seconds */
double distance = -1; /* meters */
QList<Waypoint*> buff;
- QUEUE_FOR_EACH(&master->waypoint_list, elem, tmp) {
- buff.append(reinterpret_cast<Waypoint*>(elem));
+ foreach (Waypoint* wpt, master->waypoint_list) {
+ buff.append(wpt);
}
trackfilter_split_init_rte_name(master, buff.at(0)->GetCreationTime());
void TrackFilter::trackfilter_move()
{
- queue* elem, *tmp;
-
qint64 delta = trackfilter_parse_time_opt(opt_move);
if (delta == 0) {
return;
}
for (auto track : qAsConst(track_list)) {
- QUEUE_FOR_EACH(&track->waypoint_list, elem, tmp) {
- auto wpt = reinterpret_cast<Waypoint*>(elem);
+ foreach (Waypoint* wpt, track->waypoint_list) {
wpt->creation_time = wpt->creation_time.addSecs(delta);
}
}
void TrackFilter::trackfilter_synth()
{
- queue* elem, *tmp;
-
double last_course_lat;
double last_course_lon;
double last_speed_lat = std::nan(""); /* Quiet gcc 7.3.0 -Wmaybe-uninitialized */
for (auto track : qAsConst(track_list)) {
bool first = true;
- QUEUE_FOR_EACH(&track->waypoint_list, elem, tmp) {
- auto wpt = reinterpret_cast<Waypoint*>(elem);
+ foreach (Waypoint* wpt, track->waypoint_list) {
if (opt_fix) {
wpt->fix = fix;
if (wpt->sat == 0) {
void TrackFilter::trackfilter_range()
{
QDateTime start, stop; // constructed such that isValid() is false, unlike gpsbabel::DateTime!
- queue* elem, *tmp;
if (opt_start != nullptr) {
start = trackfilter_range_check(opt_start);
while (it != track_list.end()) {
route_head* track = *it;
- QUEUE_FOR_EACH(&track->waypoint_list, elem, tmp) {
- auto wpt = reinterpret_cast<Waypoint*>(elem);
+ foreach (Waypoint* wpt, track->waypoint_list) {
bool inside;
if (wpt->creation_time.isValid()) {
bool after_start = !start.isValid() || (wpt->GetCreationTime() >= start);
if (!track_list.isEmpty()) {
QList<route_head*> new_track_list;
for (auto src : qAsConst(track_list)) {
- queue* elem, *tmp;
new_track_list.append(src);
route_head* dest = nullptr;
route_head* insert_point = src;
int trk_seg_num = 1;
bool first = true;
- QUEUE_FOR_EACH(&src->waypoint_list, elem, tmp) {
- auto wpt = reinterpret_cast<Waypoint*>(elem);
+ foreach (Waypoint* wpt, src->waypoint_list) {
if (wpt->wpt_flags.new_trkseg && !first) {
dest = route_head_alloc();
while (track_list.size() > 1) {
route_head* curr = track_list.takeAt(1);
- queue* elem, *tmp;
bool first = true;
- QUEUE_FOR_EACH(&curr->waypoint_list, elem, tmp) {
- auto wpt = reinterpret_cast<Waypoint*>(elem);
+ foreach (Waypoint* wpt, curr->waypoint_list) {
unsigned orig_new_trkseg = wpt->wpt_flags.new_trkseg;
wpt->wpt_flags.new_trkseg = 0;
void TrackFilter::trackfilter_faketime()
{
- queue* elem, *tmp;
-
assert(opt_faketime != nullptr);
faketime_t faketime = trackfilter_faketime_check(opt_faketime);
for (auto track : qAsConst(track_list)) {
- QUEUE_FOR_EACH(&track->waypoint_list, elem, tmp) {
- auto wpt = reinterpret_cast<Waypoint*>(elem);
+ foreach (Waypoint* wpt, track->waypoint_list) {
if (!wpt->creation_time.isValid() || faketime.force) {
wpt->creation_time = faketime.start;
void TrackFilter::trackfilter_segment_head(const route_head* rte)
{
- queue* elem, *tmp;
double avg_dist = 0;
int index = 0;
Waypoint* prev_wpt = nullptr;
// (Empirically determined; It's a few dozen feet.)
const double ktoo_close = 0.000005;
- QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) {
- auto wpt = reinterpret_cast<Waypoint*>(elem);
+ for (auto it = rte->waypoint_list.cbegin(); it != rte->waypoint_list.cend(); ++it) {
+ auto wpt = *it;
if (index > 0) {
double cur_dist = gcdist(RAD(prev_wpt->latitude),
RAD(prev_wpt->longitude),
}
if (cur_dist < ktoo_close) {
- if (wpt != reinterpret_cast<Waypoint*>QUEUE_LAST(&rte->waypoint_list)) {
- auto next_wpt = reinterpret_cast<Waypoint*>QUEUE_NEXT(&wpt->Q);
+ if (wpt != rte->waypoint_list.back()) {
+ auto next_wpt = *std::next(it);
if (trackfilter_points_are_same(prev_wpt, wpt) &&
trackfilter_points_are_same(wpt, next_wpt)) {
track_del_wpt(const_cast<route_head*>(rte), wpt);
#define TRACKFILTER_H_INCLUDED_
#include <QtCore/QDateTime> // for QDateTime
+#include <QtCore/QList> // for QList
#include <QtCore/QtGlobal> // for qint64
+
#include "defs.h" // for ARG_NOMINMAX, route_head (ptr only), ARG...
#include "filter.h" // for Filter
*/
+#include <cctype> // for toupper
+#include <cstdlib> // for atoi
+
+#include <QtCore/QtGlobal> // for foreach
+
#include "defs.h"
#include "filterdefs.h"
#include "transform.h"
-#include <cstdlib>
+
#if FILTERS_ENABLED
track_add_head(rte);
break;
}
-#if NEWQ
- foreach (Waypoint* wpt, waypt_list) {
-#else
- queue* elem, *tmp;
- QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- Waypoint* wpt = reinterpret_cast<Waypoint *>(elem);
-#endif
+ foreach (Waypoint* wpt, *global_waypoint_list) {
wpt = new Waypoint(*wpt);
switch (current_target) {
*/
+#include <cassert> // for assert
#include <cmath> // for fabs
#include <cstdio> // for printf, fflush, fprintf, stdout
#include <ctime> // for time_t
+#include <algorithm> // for stable_sort
#include <QtCore/QByteArray> // for QByteArray
+#include <QtCore/QChar> // for QChar
#include <QtCore/QDateTime> // for QDateTime
-#include <QtCore/QDebug>
#include <QtCore/QList> // for QList
#include <QtCore/QString> // for QString, operator==
#include <QtCore/QTime> // for QTime
#include "defs.h"
#include "garmin_fs.h" // for garmin_ilink_t, garmin_fs_s, GMSD_FIND, garmin_fs_p
#include "grtcirc.h" // for RAD, gcdist, heading_true_degrees, radtometers
-#include "queue.h" // for queue, QUEUE_INIT, dequeue, QUEUE_FOR_EACH, QUEUE_MOVE, ENQUEUE_TAIL
#include "session.h" // for curr_session, session_t
#include "src/core/datetime.h" // for DateTime
#include "src/core/logging.h" // for Warning, Fatal
-#if NEWQ
-QList<Waypoint*> waypt_list;
-queue waypt_head; // This is here solely to freak out the formats that are
-// looking into what should be a private members.
-#else
-queue waypt_head;
-#endif
+WaypointList* global_waypoint_list;
-static unsigned int waypt_ct;
static short_handle mkshort_handle;
geocache_data Waypoint::empty_gc_data;
static global_trait traits;
waypt_init()
{
mkshort_handle = mkshort_new_handle();
-#if NEWQ
- waypt_list.clear();
-#else
- QUEUE_INIT(&waypt_head);
-#endif
+ global_waypoint_list = new WaypointList;
}
void update_common_traits(const Waypoint* wpt)
void
waypt_add(Waypoint* wpt)
{
- double lat_orig = wpt->latitude;
- double lon_orig = wpt->longitude;
-#if NEWQ
- waypt_list.append(wpt);
-#else
- ENQUEUE_TAIL(&waypt_head, &wpt->Q);
- waypt_ct++;
-#endif
-
-
- if (wpt->latitude < -90) {
- wpt->latitude += 180;
- } else if (wpt->latitude > +90) {
- wpt->latitude -= 180;
- }
- if (wpt->longitude < -180) {
- wpt->longitude += 360;
- } else if (wpt->longitude > +180) {
- wpt->longitude -= 360;
- }
-
- if ((wpt->latitude < -90) || (wpt->latitude > 90.0))
- Fatal() << wpt->session->name
- << "Invalid latitude" << lat_orig << "in waypoint"
- << wpt->shortname;
- if ((wpt->longitude < -180) || (wpt->longitude > 180.0))
- Fatal() << "Invalid longitude" << lon_orig << "in waypoint"
- << wpt->shortname;
-
- /*
- * Some input may not have one or more of these types so we
- * try to be sure that we have these fields even if just by
- * copying them from elsewhere.
- */
-
- // Note tests for isNull here as some formats intentionally set "".
- // This is kind of goofy, but it emulates the C string implementation.
- if (wpt->shortname.isNull()) {
- if (!wpt->description.isNull()) {
- wpt->shortname = wpt->description;
- } else if (!wpt->notes.isNull()) {
- wpt->shortname = wpt->notes;
- } else {
- QString n;
- n.sprintf("%03d", waypt_count());
- wpt->shortname = QString("WPT%1").arg(n);
- }
- }
-
- if (wpt->description.isEmpty()) {
- if (!wpt->notes.isNull()) {
- wpt->description = wpt->notes;
- } else {
- if (!wpt->shortname.isNull()) {
- wpt->description = wpt->shortname;
- }
- }
- }
-
- update_common_traits(wpt);
-
+ global_waypoint_list->waypt_add(wpt);
}
void
waypt_del(Waypoint* wpt)
{
- // the wpt must be on waypt_list, and is assumed unique.
-#if NEWQ
- waypt_list.removeOne(wpt);
-#else
- dequeue(&wpt->Q);
- waypt_ct--;
-#endif
+ global_waypoint_list->waypt_del(wpt);
}
unsigned int
waypt_count()
{
-#if NEWQ
- return waypt_list.size();
-#else
- return waypt_ct;
-#endif
-}
-
-void
-set_waypt_count(unsigned int nc)
-{
- waypt_ct = nc;
+ return global_waypoint_list->count();
}
+// TODO: should this, and mkshort_handle, be part of main, which is the only user?
void
waypt_disp(const Waypoint* wpt)
{
void
waypt_compute_bounds(bounds* bounds)
{
- waypt_init_bounds(bounds);
-#if NEWQ
- foreach (Waypoint* waypointp, waypt_list) {
-#else
- queue* elem, *tmp;
- QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- Waypoint* waypointp = reinterpret_cast<Waypoint*>(elem);
-#endif
- waypt_add_to_bounds(bounds, waypointp);
- }
+ global_waypoint_list->waypt_compute_bounds(bounds);
}
Waypoint*
find_waypt_by_name(const QString& name)
{
-#if NEWQ
- foreach (Waypoint* waypointp, waypt_list) {
-#else
- queue* elem, *tmp;
-
- QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- Waypoint* waypointp = reinterpret_cast<Waypoint*>(elem);
-#endif
- if (waypointp->shortname == name) {
- return waypointp;
- }
- }
-
- return nullptr;
+ return global_waypoint_list->find_waypt_by_name(name);
}
-#if NEWQ
void
-waypt_flush(queue* head)
+waypt_flush_all()
{
-// TODO: This is incorrect when head != &waypt_head
-// We need to pass in a QList<Waypoint*> instead of a queue* that we ignore!
- if (head != &waypt_head) {
- if (global_opts.debug_level >= 1) {
- warning("NEWQ version of waypt_flush is unimplemented for this list.\n");
- }
- } else {
- while (!waypt_list.isEmpty()) {
- delete waypt_list.takeFirst();
- }
+ if (mkshort_handle) {
+ mkshort_del_handle(&mkshort_handle);
}
+ global_waypoint_list->flush();
}
-#else
+
void
-waypt_flush(queue* head)
+waypt_append(WaypointList* src)
{
- queue* elem, *tmp;
-
- QUEUE_FOR_EACH(head, elem, tmp) {
- Waypoint* q = reinterpret_cast<Waypoint*>(dequeue(elem));
- delete q;
- if (head == &waypt_head) {
- waypt_ct--;
- }
- }
+ src->copy(&global_waypoint_list);
}
-#endif
void
-waypt_flush_all()
+waypt_backup(WaypointList** head_bak)
{
- if (mkshort_handle) {
- mkshort_del_handle(&mkshort_handle);
- }
-#if NEWQ
- // TODO: eventually we shoud pass the list instead of the queue.
- waypt_flush(&waypt_head);
-#else
- waypt_flush(&waypt_head);
-#endif
+ global_waypoint_list->copy(head_bak);
}
void
-waypt_backup(signed int* count, queue** head_bak)
+waypt_restore(WaypointList* head_bak)
{
- queue* elem, *tmp;
- Waypoint* wpt;
- int no = 0;
-
- queue* qbackup = (queue*) xcalloc(1, sizeof(*qbackup));
- QUEUE_INIT(qbackup);
-#if NEWQ
-// Why does this code exist?
-//abort();
-#else
- QUEUE_MOVE(qbackup, &waypt_head);
- QUEUE_INIT(&waypt_head);
-#endif
-
- waypt_ct = 0;
-
- QUEUE_FOR_EACH(qbackup, elem, tmp) {
- wpt = reinterpret_cast<Waypoint*>(elem);
- waypt_add(new Waypoint(*wpt));
- no++;
- }
-
- *head_bak = qbackup;
- *count = no;
+ global_waypoint_list->restore(head_bak);
}
void
-waypt_restore(signed int count, queue* head_bak)
+waypt_swap(WaypointList& other)
{
- if (head_bak == nullptr) {
- return;
- }
+ global_waypoint_list->swap(other);
+}
-#if NEWQ
-//abort();
-#else
- waypt_flush(&waypt_head);
- QUEUE_INIT(&waypt_head);
- QUEUE_MOVE(&waypt_head, head_bak);
-#endif
- waypt_ct = count;
- xfree(head_bak);
+void
+waypt_sort(WaypointList::Compare cmp)
+{
+ global_waypoint_list->sort(cmp);
}
void
}
Waypoint::Waypoint() :
- // Q(),
latitude(0), // These should probably use some invalid data, but
longitude(0), // it looks like we have code that relies on them being zero.
altitude(unknown_alt),
session(curr_session()),
extra_data(nullptr)
{
- QUEUE_INIT(&Q);
}
Waypoint::~Waypoint()
}
Waypoint::Waypoint(const Waypoint& other) :
- // Q(other.Q),
latitude(other.latitude),
longitude(other.longitude),
altitude(other.altitude),
gc_data = new geocache_data(*other.gc_data);
}
- /*
- * It's important that this duplicated waypoint not appear
- * on the master Q.
- */
- QUEUE_INIT(&Q);
-
// deep copy fs chain data.
fs = fs_chain_copy(other.fs);
fs_chain_destroy(fs);
// allocate and copy
- // Q(rhs.Q),
latitude = rhs.latitude;
longitude = rhs.longitude;
altitude = rhs.altitude;
gc_data = new geocache_data(*rhs.gc_data);
}
- /*
- * It's important that this duplicated waypoint not appear
- * on the master Q.
- */
- QUEUE_INIT(&Q);
-
// deep copy fs chain data.
fs = fs_chain_copy(rhs.fs);
}
QDateTime dt = GetCreationTime().toUTC();
-// qDebug() << dt.toString("dd.MM.yyyy hh:mm:ss.zzz") << " CML " << microseconds;
const char* format = "yyyy-MM-ddTHH:mm:ssZ";
if (dt.time().msec()) {
{
return (gc_data == &Waypoint::empty_gc_data);
}
+
+void
+WaypointList::waypt_add(Waypoint* wpt)
+{
+ double lat_orig = wpt->latitude;
+ double lon_orig = wpt->longitude;
+ append(wpt);
+
+ if (wpt->latitude < -90) {
+ wpt->latitude += 180;
+ } else if (wpt->latitude > +90) {
+ wpt->latitude -= 180;
+ }
+ if (wpt->longitude < -180) {
+ wpt->longitude += 360;
+ } else if (wpt->longitude > +180) {
+ wpt->longitude -= 360;
+ }
+
+ if ((wpt->latitude < -90) || (wpt->latitude > 90.0))
+ Fatal() << wpt->session->name
+ << "Invalid latitude" << lat_orig << "in waypoint"
+ << wpt->shortname;
+ if ((wpt->longitude < -180) || (wpt->longitude > 180.0))
+ Fatal() << "Invalid longitude" << lon_orig << "in waypoint"
+ << wpt->shortname;
+
+ /*
+ * Some input may not have one or more of these types so we
+ * try to be sure that we have these fields even if just by
+ * copying them from elsewhere.
+ */
+
+ // Note tests for isNull here as some formats intentionally set "".
+ // This is kind of goofy, but it emulates the C string implementation.
+ if (wpt->shortname.isNull()) {
+ if (!wpt->description.isNull()) {
+ wpt->shortname = wpt->description;
+ } else if (!wpt->notes.isNull()) {
+ wpt->shortname = wpt->notes;
+ } else {
+ QString n;
+ n.sprintf("%03d", waypt_count());
+ wpt->shortname = QString("WPT%1").arg(n);
+ }
+ }
+
+ if (wpt->description.isEmpty()) {
+ if (!wpt->notes.isNull()) {
+ wpt->description = wpt->notes;
+ } else {
+ if (!wpt->shortname.isNull()) {
+ wpt->description = wpt->shortname;
+ }
+ }
+ }
+
+ if (this == global_waypoint_list) {
+ update_common_traits(wpt);
+ }
+
+}
+
+void
+WaypointList::add_rte_waypt(int waypt_ct, Waypoint* wpt, bool synth, const QString& namepart, int number_digits)
+{
+ append(wpt);
+
+ if (synth && wpt->shortname.isEmpty()) {
+ wpt->shortname = QString("%1%2").arg(namepart).arg(waypt_ct, number_digits, 10, QChar('0'));
+ wpt->wpt_flags.shortname_is_synthetic = 1;
+ }
+}
+
+void
+WaypointList::waypt_del(Waypoint* wpt)
+{
+ const int idx = this->indexOf(wpt);
+ assert(idx >= 0);
+ removeAt(idx);
+}
+
+void
+WaypointList::del_rte_waypt(Waypoint* wpt)
+{
+ const int idx = indexOf(wpt);
+ assert(idx >= 0);
+ if (wpt->wpt_flags.new_trkseg && ((idx+1) < size())) {
+ auto wpt_next = at(idx+1);
+ wpt_next->wpt_flags.new_trkseg = 1;
+ }
+ wpt->wpt_flags.new_trkseg = 0;
+ removeAt(idx);
+}
+
+/*
+ * Makes another pass over the data to compute bounding
+ * box data and populates bounding box information.
+ */
+
+void
+WaypointList::waypt_compute_bounds(bounds* bounds) const
+{
+ waypt_init_bounds(bounds);
+ foreach (const Waypoint* waypointp, *this) {
+ waypt_add_to_bounds(bounds, waypointp);
+ }
+}
+
+Waypoint*
+WaypointList::find_waypt_by_name(const QString& name) const
+{
+ foreach (Waypoint* waypointp, *this) {
+ if (waypointp->shortname == name) {
+ return waypointp;
+ }
+ }
+
+ return nullptr;
+}
+
+void
+WaypointList::flush()
+{
+ while (!isEmpty()) {
+ delete takeFirst();
+ }
+}
+
+void
+WaypointList::copy(WaypointList** dst) const
+{
+ if (*dst == nullptr) {
+ *dst = new WaypointList;
+ }
+
+ foreach (const Waypoint* wpt_old, *this) {
+ (*dst)->waypt_add(new Waypoint(*wpt_old));
+ }
+}
+
+void
+WaypointList::restore(WaypointList* src)
+{
+ if (src == nullptr) {
+ return;
+ }
+ flush();
+
+ *this = *src;
+ src->clear();
+}
+
+void WaypointList::swap(WaypointList& other)
+{
+ const WaypointList tmp_list = *this;
+ *this = other;
+ other = tmp_list;
+}
+
+void WaypointList::sort(Compare cmp)
+{
+ std::stable_sort(begin(), end(), cmp);
+}